Skip to content

Commit

Permalink
Add allow list for keys (properties) to include in errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Aug 25, 2024
1 parent 6547df8 commit cca1204
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# bedrock-vc-delivery ChangeLog

## 5.3.2 - 2024-08-dd

### Fixed
- Allow list specific error keys to include in last error.

## 5.3.1 - 2024-08-24

### Fixed
Expand Down
15 changes: 13 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import {ZcapClient} from '@digitalbazaar/ezcap';

const {config, util: {BedrockError}} = bedrock;

const ALLOWED_ERROR_KEYS = [
'message', 'name', 'type', 'data', 'errors', 'error', 'details', 'cause',
'status'
];

export async function evaluateTemplate({
workflow, exchange, typedTemplate
} = {}) {
Expand Down Expand Up @@ -106,8 +111,14 @@ export function decodeLocalId({localId} = {}) {
}

export function stripStacktrace(error) {
error = serializeError(error);
delete error.stack;
// serialize error and allow-list specific properties
const serialized = serializeError(error);
error = {};
for(const key of ALLOWED_ERROR_KEYS) {
if(serialized[key] !== undefined) {
error[key] = serialized[key];
}
}
if(error.errors) {
error.errors = error.errors.map(stripStacktrace);
}
Expand Down

0 comments on commit cca1204

Please sign in to comment.