feat: use @adobe/fetch Response to prevent helix-universal crash on Vault failure#1554
Open
abhishekgarg18 wants to merge 2 commits intomainfrom
Open
feat: use @adobe/fetch Response to prevent helix-universal crash on Vault failure#1554abhishekgarg18 wants to merge 2 commits intomainfrom
abhishekgarg18 wants to merge 2 commits intomainfrom
Conversation
879b065 to
64293f6
Compare
|
This PR will trigger a minor release when merged. |
64293f6 to
5d15941
Compare
The error response returned on Vault failure used the native Node.js `new Response()` which produces native Web API Headers. Those headers lack the `.raw()` method that `helix-universal`'s `aws-adapter.js` calls unconditionally on every response. When the dev Vault egress was blocked (403), every Lambda invocation hit the vault error handler, returned a native Response, and crashed in the adapter with `response.headers.raw is not a function` — surfaced as HTTP 500 on all API endpoints. Fix: import Response from `@adobe/fetch` (already a declared dependency). Its Headers class implements `.raw()`, making it compatible with the helix-universal adapter. Added regression tests that assert `.raw()` is callable on the 502 error response, covering bootstrap failure, Vault 403, and secret read failure scenarios. Made-with: Cursor
5d15941 to
ea9376f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Vault egress is blocked (e.g. NAT/WAF returning 403) — as happened on dev 2026-04-22 ~22:10 UTC — every API endpoint returns HTTP 500 with:
Reported in Slack `#spacecat-ops` across `spacecat-api-service`, `spacecat-audit-worker`, and all other services using this package.
Root Cause Chain
The `vault-secrets-wrapper.js` error handler was using the native Node.js `new Response()` instead of the `@adobe/fetch` version. Native Web API `Headers` lack the `.raw()` method that `helix-universal`'s `aws-adapter.js` calls unconditionally on every response before sending it back through API Gateway.
Every other middleware in this repo already does this correctly:
Fix
One-line import addition — `@adobe/fetch` is already a declared dependency of this package:
`@adobe/fetch`'s `Headers` class implements `.raw()`, restoring full compatibility with `helix-universal`'s `aws-adapter.js`.
Tests Added
5 new regression tests in `vault-secrets-wrapper.test.js`:
Impact After Release
Once a new patch version of `@adobe/spacecat-shared-vault-secrets` is published, version bumps are needed in 13 services — Renovate will auto-raise those PRs:
Related