Skip to content

chore(recording-api): fix aws error handling - #64376

Merged
z0br0wn merged 2 commits into
masterfrom
zbrown/recording-api-aws-error-name-match
Jun 17, 2026
Merged

z0br0wn merged 2 commits into
masterfrom
zbrown/recording-api-aws-error-name-match

Conversation

@z0br0wn

@z0br0wn z0br0wn commented Jun 17, 2026

Copy link
Copy Markdown
Contributor
  1. What changed and why

Three sites, one pattern: error instanceof → (error as Error)?.name === ''.

Why it was needed: CI is failing on #64357. A recent master dep change (the agent-platform merge, #63988) added more AWS SDK versions, leaving the tree with several @aws-sdk/core / @smithy/core copies. AWS SDK v3 ships each client's exception classes inside the package, so when the SDK is duplicated, an error thrown by one physical copy is not instanceof the class imported from another copy — the guard silently returns false. In the test that meant an expected ResourceNotFoundException was re-thrown, killing all 16 tests in beforeAll. The same latent failure mode sat in two production paths (graceful S3 "not found" becoming a thrown error; the keystore's concurrent-creation path throwing instead of returning the existing key).

How did you test this code?

see if ci passes

@z0br0wn
z0br0wn requested review from a team, TueHaulund, arnohillen, fasyy612 and ksvat and removed request for a team June 17, 2026 18:50
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested review from a team June 17, 2026 18:50
ghost

This comment was marked as outdated.

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore(recording-api): fix aws error hand..." | Re-trigger Greptile

@haacked
haacked requested a review from Copilot June 17, 2026 18:57
@haacked haacked added the stamphog Request AI approval (no full review) label Jun 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens AWS SDK v3 error handling in the session replay recording API and related DynamoDB keystore/test code by replacing instanceof <AwsExceptionClass> checks with string matching on error.name, avoiding failures when multiple physical copies of the AWS SDK exist in the dependency tree.

Changes:

  • Replace DynamoDB conditional write error detection with error.name === 'ConditionalCheckFailedException' to preserve the “return existing key” path.
  • Replace S3 “missing object” detection with error.name === 'NoSuchKey' to return a { ok: false, error: 'not_found' } response instead of throwing.
  • Update Localstack integration test table setup/wait loops to identify DynamoDB “table not found” via error.name === 'ResourceNotFoundException'.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
nodejs/src/session-replay/shared/keystore/dynamodb-keystore.ts Switch conditional-write exception detection from instanceof to error.name to keep concurrent-creation behavior correct under duplicated AWS SDK deps.
nodejs/src/session-replay/recording-api/recording-service.ts Switch S3 NoSuchKey handling from instanceof to error.name so missing blocks are treated as not-found reliably.
nodejs/src/session-replay/recording-api/recording-api.integration.test.ts Switch DynamoDB ResourceNotFound detection from instanceof to error.name to prevent Localstack setup teardown failures under duplicated AWS SDK deps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@z0br0wn
z0br0wn force-pushed the zbrown/recording-api-aws-error-name-match branch from 2d1c588 to 642c032 Compare June 17, 2026 19:03
@z0br0wn
z0br0wn merged commit 5ed294f into master Jun 17, 2026
175 of 176 checks passed
@z0br0wn
z0br0wn deleted the zbrown/recording-api-aws-error-name-match branch June 17, 2026 19:57
@deployment-status-posthog

deployment-status-posthog Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-06-17 21:08 UTC Run
prod-us ✅ Deployed 2026-06-17 21:28 UTC Run
prod-eu ✅ Deployed 2026-06-17 22:37 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants