fix(serenity): forward browser promise token to async jobs - #3204
Merged
Conversation
Carry the browser-supplied Semrush promise token and matching pair into the classification job without exchanging it in the request Lambda. Preserve the existing minting fallback when callers do not provide a token. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
byteclimber
temporarily deployed
to
dev-branches
September 4, 2026 13:36 — with
GitHub Actions
Inactive
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
MysticatBot
approved these changes
Sep 4, 2026
There was a problem hiding this comment.
Hey @byteclimber,
Verdict: Approve - clean, well-scoped fix with good test coverage.
Complexity: MEDIUM - small diff; API surface signal.
Changes: Defers the IMS promise-token exchange from the request Lambda to the async worker by forwarding the browser-supplied x-promise-token and its audience pair on the SQS job payload (2 files).
Non-blocking (3): minor issues and suggestions
- nit: The
decodeURIComponenttry/catch block duplicates the identical pattern fromresolveSemrushImsTokenin utils.js (same comment and all) - consider a shared helper if more decode sites appear -src/controllers/serenity.js:608 - suggestion: No test exercises
x-promise-tokenpresent with an unknownx-promise-audiencevalue - a case that should propagate a 400 fromresolvePromisePair. Pinning that contract in the controller test suite would prevent a silent regression -test/controllers/serenity.test.js - suggestion: The
promiseTokenobject passed tocreateAndEnqueueJobcarries only{ promise_token }while auto-minted tokens also includeexpires_inandtoken_type. The worker only reads.promise_tokenfor the exchange so this is functionally harmless, but a one-line comment noting the intentional shape difference would save a future reader from investigating -src/controllers/serenity.js:614
Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 12m 37s | Cost: $5.79 | Commit: f827d267ac9be004a2e3dc050529c82f5f26514b
If this code review was useful, please react with 👍. Otherwise, react with 👎.
Resolve Serenity async promise-token conflicts while preserving mainline validation and no pre-enqueue exchange coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
This PR will trigger a patch release when merged. |
byteclimber
temporarily deployed
to
dev-branches
September 10, 2026 15:49 — with
GitHub Actions
Inactive
solaris007
pushed a commit
that referenced
this pull request
Sep 11, 2026
## [1.807.1](v1.807.0...v1.807.1) (2026-09-11) ### Bug Fixes * **serenity:** forward browser promise token to async jobs ([#3204](#3204)) ([e551703](e551703))
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.
Summary
Makes browser-initiated async Serenity prompt classification preserve the caller-supplied Semrush promise token across the SQS boundary. The request Lambda no longer exchanges that token before enqueueing; it stores the token and matching promise pair on the job so the worker performs the exchange immediately before its Semrush work.
Companion backend fix for adobe/project-elmo-ui#3002.
Problem
The UI authenticates to SpaceCat with its session JWT and separately sends
x-promise-tokenplusx-promise-audience: semrush. The async controller previously exchanged the supplied token in the request Lambda, then calledcreateAndEnqueueJobwithout it. The runner consequently tried to mint a replacement from the session JWT inAuthorization, which IMS rejects.Changes
async: trueprompt creates.x-promise-tokenas the job promise token.Validation
npx mocha --timeout 10000 test/controllers/serenity.test.js test/support/serenity/async-job-runner.test.js— 254 passingnpx eslint src/controllers/serenity.js test/controllers/serenity.test.jsnpm run type-checknpm run buildandnpm run build:workerChange Management