Repository navigation
fix(apps-vtex): create Master Data documents with app credentials - #743
Merged
Merged
Conversation
VTEX now rejects anonymous writes to /api/dataentities. The client only attaches App Key/Token when no shopper cookie is passed, so a create called with the cookie went out anonymous and failed. masterdata.create now leaves the cookie out whenever credentials are configured; its response is just the document ids, so there is nothing to unmask. Without credentials it still forwards the cookie. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
JonasJesus42
approved these changes
Oct 21, 2026
|
🎉 This PR is included in version 8.5.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
What
vtex.masterdata.createnow sendsX-VTEX-API-AppKey/X-VTEX-API-AppTokenwhenever the client is configured with them, leaving the shopper's cookie out of that call.Why
VTEX is rejecting anonymous writes to
/api/dataentities.call()only attaches app credentials when no cookie is passed (so shopper-scoped calls like the orderForm never come back with unmasked profile data). Amasterdata.createcalled with the shopper's cookie therefore went out without credentials and failed.The create response is only
Id/Href/DocumentId, so sending it as the app unmasks nothing. The "no credentials next to a cookie" rule still holds: when credentials are used, the cookie is dropped.masterdata.searchis unchanged.Equivalent fix in deco-cx/apps: deco-cx/apps#1688
Note for sites
Sites need
appKey/appTokenwith a role that has Dynamic Storage → Insert or update document. A site route or server function that exposesmasterdata.createto the browser should pin the entity and whitelist fields, since writes now carry store credentials.Testing
vtexClient.test.tscovering both cases (with and without credentials).apps-vtextests (66), typecheck and biome pass.🤖 Generated with Claude Code
Summary by cubic
Fixes
vtex.masterdata.createso documents are written with store app credentials whenever they're configured, since VTEX now rejects anonymous writes to/api/dataentities.Passing the shopper's cookie had made the client skip credentials, so those writes failed. With credentials configured, the call now goes out as the app and leaves the cookie out — safe because the create response only returns document IDs, nothing to unmask. Without credentials the behavior is unchanged, and
masterdata.searchis untouched.Sites need an
appKey/appTokenwith the Dynamic Storage → Insert or update document role. Any route or server function exposingmasterdata.createto the browser should pin the entity and whitelist fields, because writes now carry store credentials.Written for commit c750bc1. Summary will update on new commits.