Skip to content

Commit

Permalink
Fixed a bug where continueOnError would be missing required metadata …
Browse files Browse the repository at this point in the history
…property
  • Loading branch information
SvenHoeffler committed Jul 3, 2024
1 parent 2d36220 commit d604dbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions templates/lib/actions/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenDa
);

const specPath = spec.paths[pathName];
const specPathGeneralParams = specPath.parameters? specPath.parameters.map(({ name }) => name) : [];
const specPathGeneralParams = specPath.parameters ? specPath.parameters.map(({ name }) => name) : [];
const specPathParameters = specPath[method].parameters ? specPath[method].parameters.map(({ name }) => name) : [];
specPathParameters.push(...specPathGeneralParams);

Expand All @@ -61,7 +61,7 @@ async function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenDa

let parameters = {};
for (let param of specPathParameters) {
if (body[param]){
if (body[param]) {
parameters[param] = body[param];
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ async function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenDa
this.logger.info("Execution finished");
} catch (e) {
if (continueOnError === true) {
this.emit('data', { data: {} });
this.emit('data', { data: {}, metadata: {} });
} else {
this.emit('error', e);
}
Expand Down
4 changes: 2 additions & 2 deletions templates/lib/triggers/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
);

const specPath = spec.paths[pathName];
const specPathGeneralParams = specPath.parameters? specPath.parameters.map(({ name }) => name) : [];
const specPathGeneralParams = specPath.parameters ? specPath.parameters.map(({ name }) => name) : [];
const specPathParameters = specPath[method].parameters ? specPath[method].parameters.map(({ name }) => name) : [];
specPathParameters.push(...specPathGeneralParams);

Expand Down Expand Up @@ -159,7 +159,7 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
logger.info("Execution finished");
} catch (e) {
if (continueOnError === true) {
this.emit('data', { data: {} });
this.emit('data', { data: {}, metadata: {} });
} else {
this.emit('error', e);
}
Expand Down
7 changes: 7 additions & 0 deletions templates/lib/utils/helpers.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {
isMicrosoftJsonDate,
getInitialSnapshotValue,
compareDate,
} = require("./helpers");
const dayjs = require('dayjs');

Expand All @@ -15,8 +16,14 @@ describe("Helpers", () => {
const date = isMicrosoftJsonDate("2020-01-01T00:00:00.000Z");
expect(date).toEqual(null);
});

it("should handle integer comparisons", () => {
const result = compareDate(4, 0);
expect(result).toEqual(true);
});
});


describe("getInitialSnapshotValue", () => {
it("should return null date when nothing is set", () => {
const initialSnapshot = getInitialSnapshotValue({}, {});
Expand Down

0 comments on commit d604dbe

Please sign in to comment.