fix(plugin-sdk): carry contentAccess from definePlugin config into the manifest - #333
Open
mostafasadeghidev wants to merge 1 commit into
Open
Conversation
…manifest DefinePluginConfig had no contentAccess field and definePlugin() never copied it into the manifest it returns, even though PluginManifest supports it and the CLI's own content-editor scaffold passes it. Any plugin built with the CLI silently lost its per-table allowlist, so every cms.content.* call failed closed at runtime despite the operator granting the permissions. - Add contentAccess to DefinePluginConfig and snapshot it into the manifest (key omitted when undefined, matching the other optional fields). - Lint: warn when a declared cms.content.* permission has no contentAccess entry carrying the matching mode (permission with no consumer — fails closed per table+mode). The missing-allowlist case stays a single hard error from parsePluginManifest. - Lint: report source-scan finding paths POSIX-style on Windows. - Scaffold: drop the dead `entrypoints:` line from the content-editor template — not a DefinePluginConfig field (an IDE type error for authors, silently ignored at runtime) and redundant, since the build auto-wires entrypoints.server from server/index.ts. - Fix the stale definePlugin docblock that showed editor/server/frontend config fields which don't exist and a dead scripts/build-plugin.ts path. - Tests: definePlugin contentAccess deep-copy + omission; lint warning fires/stays quiet correctly; end-to-end regression scaffolding the content-editor template and asserting it lints clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mostafasadeghidev
marked this pull request as ready for review
August 3, 2026 03:53
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 changed
definePlugin()silently droppedcontentAccess:DefinePluginConfighad no such field and the builder never copied it into the manifest it returns — even thoughPluginManifestsupportscontentAccess?: ContentAccessEntry[]and the CLI's own content-editor scaffold emits a config that passes it. Any plugin built with the CLI lost its per-table allowlist, so everycms.content.*call failed closed at runtime despite the operator granting the permissions.definePlugin(definePlugin.ts):contentAccess?: ContentAccessEntry[]added toDefinePluginConfig, snapshotted into the manifest (entries + modes arrays copied), key omitted when undefined — same pattern as the other optional fields. Also fixed the stale docblock that showededitor:/server:/frontend:config fields that don't exist and referenced a deadscripts/build-plugin.tspath.cms.content.*permission has nocontentAccessentry carrying the matching mode — a permission with no consumer; the host fails closed per table+mode. The missing-allowlist case (permissions with zero entries) stays a single hard error viaparsePluginManifest, which lint already runs — before this fix that error fired misleadingly even for authors who did declare entries. Also: source-scan finding paths are now reported POSIX-style on Windows.entrypoints: { server: 'server/index.js' }line from the content-editor template — same class of bug (config fieldDefinePluginConfigdoesn't accept: an IDE type error for authors, silently ignored at runtime) and redundant, sinceinstatic-plugin buildauto-wiresentrypoints.serverfromserver/index.ts.Why
Operator grants the
cms.content.*permissions on install, plugin still gets 403s on every content call — the manifest never carried the allowlist the author wrote. Fails closed, no error at build time, nothing pointing at the cause.Impact
CLI-built content plugins work as authored.
instatic-plugin lintnow catches the "permission declared but unusable" case pre-upload. Scaffolded configs typecheck clean in the author's IDE.Tests
definePlugincopiescontentAccessas an independent deep copy (input mutation doesn't leak) and omits the key entirely when unset (theValue.Convertround-trip footgun).contentAccess, and assert it lints with zero findings — this exact path failed before the fix.Verification
Full
bun testshows 299 pre-existing failures (symlink swap semantics, site-document save, etc.) — verified byte-identical with and without this diff on the same machine (Windows-environmental, e.g. symlink privileges), not related to this change.