Repository navigation
fix(admin-sdk): skip read privilege check for empty entity collections - #1390
Björn Meyer (BrocksiNet) merged 3 commits into
Conversation
The dataset validator required read privileges for every entity collection in a message, including empty ones. The Administration hydrates every to-many relationship as an EntityCollection, so a single entity like language carries dozens of empty association collections. Apps had to request read access to entities they never receive, and broke whenever core or a plugin added a new association. Empty collections contain no entity data, so skip the read check for them. Create, update and delete are still checked, because an emptied collection sent back via datasetUpdate can delete associations.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09a64aa462
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
|
Codex (@codex) review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback". |
@shopware-ag/meteor-admin-sdk
@shopware-ag/meteor-component-library
@shopware-ag/create-meteor-extension
@shopware-ag/meteor-icon-kit
@shopware-ag/meteor-prettier-config
@shopware-ag/stylelint-plugin-meteor
@shopware-ag/meteor-tokens
commit: |
What?
The dataset privilege validator (
_internals/validator/index.ts) no longer requiresreadprivileges for empty entity collections. Create, update and delete privileges are still checked for them.Why?
The validator walks every
__Entity__and__EntityCollection__in a dataset message, at any depth, and requiresread:<entityName>for each one, whether or not the collection holds any entities.The Shopware Administration hydrates every to-many relationship from the JSON:API response as an
EntityCollection, even when the association was never loaded (entity-hydrator.data.ts,hydrateToMany). So a dataset that contains a single entity carries an empty collection for each of its to-many associations. Thelanguageentity alone has about 50 of them, one per*_translationtable.Result: an app subscribing to a dataset that contains a language (for example via an order, customer or sales channel) has to hold
readprivileges for every translation entity in the system. It also breaks each time core or a plugin adds another association, even though the app never receives any of that data.A current example: Shopware core added MCP support for apps, which introduced
app_mcp_tool_translation,app_mcp_prompt_translationandapp_mcp_resource_translationwith reverse associations onlanguage. The DALDefinitionValidatorrequires those reverse associations. Existing apps now fail with:This pushes developers towards over-privileged apps. They add read access for entities they don't use just to silence the error.
Related reports of the same false positive:
selectors: ['media']still requiresread:product_media)How?
__EntityCollection__with no entities, no__total__and no__aggregations__is skipped for thereadprivilege only. That is exactly the placeholder the Administration's hydrator creates for unloaded associations. It contains no records, so no entity data is disclosed to the app. Empty pages that carry a total (including0) or aggregations still requireread, because those would disclose counts or aggregate values.MissingPrivilegesErrornaming the exact privilege. Loading an association itself through the SDK repository is enforced by the server ACL anyway, because those requests carry thesw-app-integration-idheader.datasetUpdatecould otherwise cause associated entities to be deleted when the Administration saves.selectDatais unchanged. If an app explicitly selects a collection, it still needsreadfor that entity.docs/admin-sdk/concepts/selectors.mdnow explains that without selectors the whole dataset, including nested associations, is checked, and that empty collections are exempt.Testing?
New
src/_internals/validator/index.spec.tsuses the real serializer on alanguageentity with anapp_mcp_tool_translationcollection. It covers:readcheck.read.read.0, or aggregations still requiresread.create,updateanddelete(thedatasetUpdatepath).With the fix, the full admin-sdk unit suite passes (24 suites, 239 tests), and
eslintandtsc --noEmitare clean.Screenshots (optional)
Anything Else?
@shopware-ag/meteor-admin-sdk. Shopware core has to bump the SDK in the Administration to pick this up.datasetUpdatemessages still require write privileges for every nested collection, including empty ones. Relaxing that needs a separate look at how the Administration builds changesets from updated datasets.