Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Merge pull request #37 from pagopa/IOPID-106
Browse files Browse the repository at this point in the history
[#IOPID-106] Add retry info to `HandlePubKeyRevoke` exception
  • Loading branch information
gquadrati authored Apr 14, 2023
2 parents b0e9340 + 21a7159 commit ceef918
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
28 changes: 21 additions & 7 deletions HandlePubKeyRevoke/__tests__/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const contextMock = {
log: {
error: jest.fn()
},
executionContext: {}
executionContext: { retryContext: { retryCount: 1, maxRetryCount: 5 } }
} as any;

const mockAppinsights = {
Expand Down Expand Up @@ -98,7 +98,9 @@ describe("handleRevoke", () => {
expect.objectContaining({
properties: expect.objectContaining({
detail: "PERMANENT",
name: "lollipop.pubKeys.revoke.failure"
name: "lollipop.pubKeys.revoke.failure",
retryCount: "1",
maxRetryCount: "5"
})
})
);
Expand Down Expand Up @@ -131,7 +133,9 @@ describe("handleRevoke", () => {
fatal: "false",
isSuccess: "false",
modelId: "",
name: "lollipop.pubKeys.revoke.failure"
name: "lollipop.pubKeys.revoke.failure",
retryCount: "1",
maxRetryCount: "5"
})
})
);
Expand Down Expand Up @@ -241,7 +245,9 @@ describe("handleRevoke", () => {
expect.objectContaining({
properties: expect.objectContaining({
detail: "PERMANENT",
name: "lollipop.pubKeys.revoke.failure"
name: "lollipop.pubKeys.revoke.failure",
retryCount: "1",
maxRetryCount: "5"
})
})
);
Expand Down Expand Up @@ -281,7 +287,9 @@ describe("handleRevoke", () => {
expect.objectContaining({
properties: expect.objectContaining({
detail: "PERMANENT",
name: "lollipop.pubKeys.revoke.failure"
name: "lollipop.pubKeys.revoke.failure",
retryCount: "1",
maxRetryCount: "5"
})
})
);
Expand Down Expand Up @@ -325,7 +333,9 @@ describe("handleRevoke", () => {
expect.objectContaining({
properties: expect.objectContaining({
detail: "TRANSIENT",
name: "lollipop.pubKeys.revoke.failure"
name: "lollipop.pubKeys.revoke.failure",
retryCount: "1",
maxRetryCount: "5"
})
})
);
Expand Down Expand Up @@ -364,6 +374,8 @@ describe("handleRevoke", () => {
properties: expect.objectContaining({
detail: "TRANSIENT",
name: "lollipop.pubKeys.revoke.failure",
retryCount: "1",
maxRetryCount: "5",
errorMessage: expect.stringContaining(
"Cannot find a master lollipopPubKey"
)
Expand Down Expand Up @@ -407,7 +419,9 @@ describe("handleRevoke", () => {
errorMessage: expect.stringContaining(
"Cannot decode a VALID master lollipopPubKey"
),
name: "lollipop.pubKeys.revoke.failure"
name: "lollipop.pubKeys.revoke.failure",
retryCount: "1",
maxRetryCount: "5"
})
})
);
Expand Down
10 changes: 8 additions & 2 deletions HandlePubKeyRevoke/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,16 @@ export const handleRevoke = (
errorMessage: error,
fatal: PermanentFailure.is(err).toString(),
isSuccess: "false",
maxRetryCount: String(
context.executionContext.retryContext?.maxRetryCount ?? "undefined"
),
modelId: err.modelId ?? "",
name: "lollipop.pubKeys.revoke.failure"
name: "lollipop.pubKeys.revoke.failure",
retryCount: String(
context.executionContext.retryContext?.retryCount ?? "undefined"
)
},
tagOverrides: { samplingEnabled: String(isTransient) }
tagOverrides: { samplingEnabled: "false" }
});
context.log.error(error);
if (isTransient) {
Expand Down

0 comments on commit ceef918

Please sign in to comment.