Skip to content

fix: forward an={account} on VTEX ID outbound calls - #697

Merged
iago1501 merged 1 commit into
masterfrom
fix/vtexid-an-querystring
May 22, 2026
Merged

fix: forward an={account} on VTEX ID outbound calls#697
iago1501 merged 1 commit into
masterfrom
fix/vtexid-an-querystring

Conversation

@vsseixaso

@vsseixaso vsseixaso commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Some axios-based callers in node/resolvers/auth and node/resolvers/profile/services were hitting vtexid.vtex.com.br without the an={account} query string. This caused the backend to reject some flows in production — for example, pub/authentication/accesskey/send returns HTTP 401 from storecomponents/master and the same call returns 200 once an=storecomponents is present (validated below).

This change adds ?an={account} to every direct call that previously omitted it, while keeping the host (vtexid.vtex.com.br) and the route shape unchanged.

Endpoints touched

Path Status
pub/authentication/accesskey/validate adds an
pub/authentication/accesskey/send adds an
pub/authentication/classic/validate adds an
pub/authentication/classic/setpassword adds an
pvt/user/detailedinfo adds an
pub/authentication/start (sessionToken) intentionally not changed

pub/authentication/start is left without an because the backend validates that the host of callbackUrl and returnUrl matches the account in an. Callers in this codebase pass relative URLs (/), so adding an there returns HTTP 400 (The host and {callbackUrl,returnUrl} accounts do not match).

getAuthenticatedUser and IdentityClient.getUserWithToken already propagate an (via JanusClient and explicitly, respectively); loginSessions/logOutFromSession already had an in the URL.

Files

  • node/resolvers/paths.ts — URL builders accept account and append &an=${account}.
  • node/resolvers/auth/index.ts — 5 call sites pass ioContext.account.
  • node/__tests__/resolvers/paths.test.ts — 7 unit tests for the URL builders (including a regression guard for loginSessions/logOutFromSession and an explicit assertion that sessionToken does not carry an).
  • CHANGELOG.md — entry under [Unreleased] - Fixed.

Test plan

Unit suite (node/):

  • yarn test → 871/871 green.

End-to-end via curl, comparing storecomponents/master (production, without the fix) against storecomponents/vulnsg (with this branch linked):

Scenario master vulnsg Result
loginOptions query 200 OK 200 OK (byte-identical) no regression
classicSignIn mutation (invalid creds) WrongCredentials WrongCredentials (byte-identical) no regression
sendEmailVerification mutation (fresh email) HTTP 401 { sendEmailVerification: true } (200 OK) fix unblocks the flow

Direct curls to vtexid.vtex.com.br confirmed that accesskey/{validate,send}, classic/{validate,setpassword} and pvt/user/detailedinfo accept an= without changing the response shape; only pub/authentication/start rejects an when callbackUrl/returnUrl are relative — hence the carve-out.

@vsseixaso
vsseixaso requested review from a team as code owners May 20, 2026 18:35
@vsseixaso
vsseixaso requested review from gabpaladino, leo-prange-vtex and vmourac-vtex and removed request for a team May 20, 2026 18:35
@vtex-io-docs-bot

Copy link
Copy Markdown

Beep boop 🤖

Thank you so much for keeping our documentation up-to-date ❤️

@vtex-io-ci-cd

vtex-io-ci-cd Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vsseixaso
vsseixaso requested review from iago1501, mendescamara and monteirogc and removed request for a team, gabpaladino, leo-prange-vtex and vmourac-vtex May 20, 2026 18:36
@vsseixaso
vsseixaso force-pushed the fix/vtexid-an-querystring branch from b2abcab to e9332ee Compare May 20, 2026 18:38
mendescamara
mendescamara previously approved these changes May 20, 2026

@mendescamara mendescamara 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.

The axios-based callers in `node/resolvers/auth` and
`node/resolvers/profile/services` were hitting `vtexid.vtex.com.br`
without the `an={account}` query string, causing the backend to
reject some flows (e.g. `accesskey/send` returning HTTP 401 on
master, which the same call returns 200 once `an=` is present).

Adds `?an={account}` to:

- `pub/authentication/accesskey/validate`
- `pub/authentication/accesskey/send`
- `pub/authentication/classic/validate`
- `pub/authentication/classic/setpassword`
- `pvt/user/detailedinfo`

`pub/authentication/start` (sessionToken) is intentionally kept
without `an`: the backend validates that the host of `callbackUrl`
and `returnUrl` matches the account in `an`, which would break
callers that pass relative URLs (`/`).

Co-authored-by: Cursor <cursoragent@cursor.com>
@iago1501
iago1501 merged commit 7a1ca9a into master May 22, 2026
8 of 9 checks passed
@iago1501
iago1501 deleted the fix/vtexid-an-querystring branch May 22, 2026 17:31
@vtex-io-ci-cd

vtex-io-ci-cd Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Your PR has been merged! App is being published. 🚀
Version 2.177.1 → 2.177.2

After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:

vtex deploy vtex.store-graphql@2.177.2

After that your app will be updated on all accounts.

For more information on the deployment process check the docs. 📖

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants