fix(vtex): always authenticate masterdata createDocument
Merged
AK
4d ago+16+16+01234567890123456789-21-21-01234567890123456789
What
vtex/actions/masterdata/createDocument now always calls Master Data through vcs, which sends X-VTEX-API-AppKey / X-VTEX-API-AppToken when the VTEX app has them configured.
Why
VTEX is rejecting anonymous writes to /api/dataentities. By default (isPrivateEntity unset) this action went through vcsDeprecated, which never sends App Key/Token โ only the shopper's cookie โ so document creation started failing.
- The action is already
defaultVisibility = "private"(not invokable from the browser), so always using the store credentials does not expose them. updateDocumentandsearchDocumentsalready usevcsโ no change.isPrivateEntityis kept inPropsas@deprecated/@hideand ignored, so existing blocks and TS callers don't break.
Impact on sites
- Sites with App Key/Token configured: creation is now authenticated and works again.
- Sites without them: request stays anonymous, same as before (no regression, still fails if VTEX blocks it). They need to configure a dedicated App Key/Token whose role has Dynamic Storage โ Insert or update document.
- Sites that wrap this action in their own public action should pin the
acronymand whitelist fields, since writes now carry store credentials.
Testing
deno task check(fmt, lint, check) passes.- Not yet tested against a live VTEX account with credentials.
๐ค Generated with Claude Code
Summary by cubic
Fixes createDocument so Master Data writes always go through vcs, which sends the app's App Key/Token when configured, because VTEX now rejects anonymous writes to /api/dataentities. The isPrivateEntity prop is deprecated and ignored; vcsDeprecated is no longer used.
Impact
- Sites with App Key/Token configured: document creation is authenticated again.
- Sites without them: requests stay anonymous, unchanged; configure credentials with Dynamic Storage โ Insert or update document.
- Wrapper actions should pin the
acronymand whitelist fields since writes now carry store credentials.
Summary by CodeRabbit
-
Bug Fixes
- Document creation requests now consistently use the appโs configured credentials.
- Requests no longer vary based on the deprecated private-entity setting, providing more predictable behavior.
-
Deprecation
- The private-entity configuration is deprecated and is now ignored for document creation requests.