Skip to content

Commit

Permalink
Redrive Trace Merging Fix (#605)
Browse files Browse the repository at this point in the history
Account for missing redrive count in Step Functions trace merging. While we expect the context object to always have `Execution.RedriveCount`, some customers context objects don't have this value.
  • Loading branch information
avedmala authored Jan 2, 2025
1 parent 8438492 commit c726f30
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
1 change: 0 additions & 1 deletion src/trace/context/extractors/step-function.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe("StepFunctionEventTraceExtractor", () => {
RoleArn:
"arn:aws:iam::425362996713:role/service-role/StepFunctions-abhinav-activity-state-machine-role-22jpbgl6j",
StartTime: "2024-12-04T19:38:04.069Z",
RedriveCount: 0,
},
State: {
Name: "Lambda Invoke",
Expand Down
10 changes: 0 additions & 10 deletions src/trace/step-function-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,6 @@ describe("StepFunctionContextService", () => {
},
},
],
[
"Execution RedriveCount is not a number",
{
...legacyStepFunctionEvent,
Execution: {
...legacyStepFunctionEvent.Execution,
RedriveCount: "0",
},
},
],
[
"State is not defined",
{
Expand Down
3 changes: 1 addition & 2 deletions src/trace/step-function-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export class StepFunctionContextService {
if (this.isValidContextObject(event)) {
return {
execution_id: event.Execution.Id,
redrive_count: event.Execution.RedriveCount.toString(),
redrive_count: (event.Execution.RedriveCount ?? "0").toString(),
state_entered_time: event.State.EnteredTime,
state_name: event.State.Name,
};
Expand All @@ -228,7 +228,6 @@ export class StepFunctionContextService {
private isValidContextObject(context: any): boolean {
return (
typeof context?.Execution?.Id === "string" &&
typeof context?.Execution?.RedriveCount === "number" &&
typeof context?.State?.EnteredTime === "string" &&
typeof context?.State?.Name === "string"
);
Expand Down

0 comments on commit c726f30

Please sign in to comment.