Skip to content

fix(admin-sdk): skip read privilege check for empty entity collections - #1390

Merged
Björn Meyer (BrocksiNet) merged 3 commits into
mainfrom
fix/admin-sdk-skip-read-check-empty-collections
Oct 6, 2026
Merged

Björn Meyer (BrocksiNet) merged 3 commits into
mainfrom
fix/admin-sdk-skip-read-check-empty-collections

Conversation

@BrocksiNet

@BrocksiNet Björn Meyer (BrocksiNet) commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What?

The dataset privilege validator (_internals/validator/index.ts) no longer requires read privileges 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 requires read:<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. The language entity alone has about 50 of them, one per *_translation table.

Result: an app subscribing to a dataset that contains a language (for example via an order, customer or sales channel) has to hold read privileges 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_translation and app_mcp_resource_translation with reverse associations on language. The DAL DefinitionValidator requires those reverse associations. Existing apps now fail with:

Error: Your app is missing the privileges read:app_mcp_tool_translation, read:app_mcp_prompt_translation, read:app_mcp_resource_translation for action "datasetSubscribe".

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:

How?

  • An __EntityCollection__ with no entities, no __total__ and no __aggregations__ is skipped for the read privilege 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 (including 0) or aggregations still require read, because those would disclose counts or aggregate values.
  • Collections with entities are checked exactly as before. If an app really receives association data, it still gets a MissingPrivilegesError naming the exact privilege. Loading an association itself through the SDK repository is enforced by the server ACL anyway, because those requests carry the sw-app-integration-id header.
  • Create, update and delete are still checked for empty collections. An app sending back an emptied collection via datasetUpdate could otherwise cause associated entities to be deleted when the Administration saves.
  • The explicit selector check in selectData is unchanged. If an app explicitly selects a collection, it still needs read for that entity.
  • docs/admin-sdk/concepts/selectors.md now 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.ts uses the real serializer on a language entity with an app_mcp_tool_translation collection. It covers:

  • An empty collection passes the read check.
  • A collection with entities still requires read.
  • The top-level entity still requires read.
  • An empty collection with a total, a total of 0, or aggregations still requires read.
  • An empty collection still requires create, update and delete (the datasetUpdate path).

With the fix, the full admin-sdk unit suite passes (24 suites, 239 tests), and eslint and tsc --noEmit are clean.

Screenshots (optional)

Anything Else?

  • Includes a patch changeset for @shopware-ag/meteor-admin-sdk. Shopware core has to bump the SDK in the Administration to pick this up.
  • Not addressed here: incoming datasetUpdate messages 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.

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

vercel Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
meteor-docs Ready Ready Preview Oct 6, 2026 2:21pm UTC
meteor-storybook Ready Ready Preview Oct 6, 2026 2:21pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T05:47:06.746062Z b074441 Manual request
ℹ️ About Codex in GitHub

Your 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/admin-sdk/src/_internals/validator/index.ts Outdated
@BrocksiNet

Copy link
Copy Markdown
Contributor Author

Codex (@codex) review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: b074441dcf

ℹ️ 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".

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@shopware-ag/meteor-admin-sdk

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-admin-sdk@1390

@shopware-ag/meteor-component-library

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-component-library@1390

@shopware-ag/create-meteor-extension

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/create-meteor-extension@1390

@shopware-ag/meteor-icon-kit

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-icon-kit@1390

@shopware-ag/meteor-prettier-config

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-prettier-config@1390

@shopware-ag/stylelint-plugin-meteor

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/stylelint-plugin-meteor@1390

@shopware-ag/meteor-tokens

npm i https://pkg.pr.new/shopware/meteor/@shopware-ag/meteor-tokens@1390

commit: 44372f1

@BrocksiNet
Björn Meyer (BrocksiNet) enabled auto-merge (squash) October 6, 2026 14:15
@BrocksiNet
Björn Meyer (BrocksiNet) merged commit 17f05b1 into main Oct 6, 2026
11 checks passed
@BrocksiNet
Björn Meyer (BrocksiNet) deleted the fix/admin-sdk-skip-read-check-empty-collections branch October 6, 2026 14:23

This branch was successfully deployed

2 active deployments
Preview – meteor-docs — 663fff02 Deployed Oct 6, 2026 by vercel[bot]
Preview – meteor-storybook — 663fff02 Deployed Oct 6, 2026 by vercel[bot]
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.

4 participants