Skip to content

feat: Register definition issue checkers for plugin schema validation#834

Merged
kingston merged 14 commits into
mainfrom
kingston/eng-1074-show-plugin-schema-merger-errors-in-issues
Mar 19, 2026
Merged

feat: Register definition issue checkers for plugin schema validation#834
kingston merged 14 commits into
mainfrom
kingston/eng-1074-show-plugin-schema-merger-errors-in-issues

Conversation

@kingston

@kingston kingston commented Mar 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Schema validation now surfaces model-drift warnings globally in the issues panel
    • Preview diffs for suggested schema fixes with an inline diff viewer
  • Bug Fixes

    • Refreshed definition alert layout and styling for clearer pending-changes presentation
  • Chores

    • Registered schema issue checkers for auth, local-auth, rate-limit, and storage plugins
    • Reorganized example projects (auth/users) and added model defaults
    • CLI version bumped to 0.6.2

@changeset-bot

changeset-bot Bot commented Mar 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d14322

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@baseplate-dev/plugin-auth Patch
@baseplate-dev/project-builder-lib Patch
@baseplate-dev/plugin-storage Patch
@baseplate-dev/plugin-rate-limit Patch
@baseplate-dev/project-builder-common Patch
@baseplate-dev/create-project Patch
@baseplate-dev/project-builder-cli Patch
@baseplate-dev/project-builder-dev Patch
@baseplate-dev/project-builder-server Patch
@baseplate-dev/project-builder-web Patch
@baseplate-dev/plugin-email Patch
@baseplate-dev/plugin-observability Patch
@baseplate-dev/plugin-payments Patch
@baseplate-dev/plugin-queue Patch
@baseplate-dev/project-builder-test Patch
@baseplate-dev/code-morph Patch
@baseplate-dev/core-generators Patch
@baseplate-dev/fastify-generators Patch
@baseplate-dev/react-generators Patch
@baseplate-dev/sync Patch
@baseplate-dev/tools Patch
@baseplate-dev/ui-components Patch
@baseplate-dev/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@kingston has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 59 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cdf59e5a-7eef-4acd-917a-9054ed957ce6

📥 Commits

Reviewing files that changed from the base of the PR and between 879d518 and 1d14322.

⛔ Files ignored due to path filters (2)
  • examples/blog-with-auth/baseplate/snapshots/backend/manifest.json is excluded by !**/baseplate/snapshots/**
  • examples/todo-with-better-auth/baseplate/snapshots/transactional/manifest.json is excluded by !**/baseplate/snapshots/**
📒 Files selected for processing (1)
  • examples/blog-with-auth/apps/backend/baseplate/file-id-map.json
📝 Walkthrough

Walkthrough

Adds global plugin-level schema issue checkers (auth, better-auth, rate-limit, storage) that detect model drift and offer fix actions. Exposes previewIssueFix in project-builder-lib to compute fix diffs. Updates web UI to preview diffs and apply fixes. Reorganizes example auth/users features and adjusts import paths and project definitions.

Changes

Cohort / File(s) Summary
Plugin Schema Checkers
plugins/plugin-auth/src/better-auth/core/schema/schema-issue-checker.ts, plugins/plugin-auth/src/local-auth/core/schema/schema-issue-checker.ts, plugins/plugin-rate-limit/src/rate-limit/core/schema/schema-issue-checker.ts, plugins/plugin-storage/src/storage/core/schema/schema-issue-checker.ts
New factory functions create*SchemaChecker(pluginKey) that diff current definitions against plugin partials, emit a single warning issue when models diverge, and provide a fix action to apply merged definitions.
Plugin Initialization Wiring
plugins/plugin-auth/src/better-auth/core/common.ts, plugins/plugin-auth/src/local-auth/core/common.ts, plugins/plugin-rate-limit/src/rate-limit/core/common.ts, plugins/plugin-storage/src/storage/core/common.ts
Plugins now declare an issueCheckers: definitionIssueCheckerSpec dependency, accept issueCheckers in initialize, and register their schema checker via issueCheckers.checkers.set(pluginKey, ...).
Definition Issue Utilities
packages/project-builder-lib/src/parser/definition-issue-utils.ts, packages/project-builder-lib/src/parser/index.ts
Added previewIssueFix(issue, container) which applies a fix to a draft definition, serializes before/after, and returns a DefinitionDiff; re-exported from parser index.
Definition Diff UI
packages/project-builder-web/src/components/definition-warning-dialog/definition-warning-dialog.tsx, packages/project-builder-lib/src/web/components/definition-diff-alert.tsx
Warning dialog now shows per-issue preview button and expandable diff panel (JSON or JsonDiffViewer). DefinitionDiffAlert styling/layout updated (alert → bordered container).
UI Primitive Typing
packages/ui-components/src/components/ui/button/button.tsx
Button prop type changed from React.ComponentProps<'button'> to ButtonPrimitive.Props.
Base UI Interaction
packages/project-builder-web/src/app/project-sync-modal/project-sync-modal.tsx
Sync button handler updated to call e.preventBaseUIHandler() instead of e.preventDefault().
Local Auth Editor
plugins/plugin-auth/src/local-auth/core/components/local-auth-definition-editor.tsx
Removed explicit upToDateMessage prop when rendering DefinitionDiffAlert.
Example: Auth/Users Reorg
examples/blog-with-auth/apps/backend/src/modules/accounts/..., examples/blog-with-auth/apps/backend/file-id-map.json, examples/blog-with-auth/baseplate/project-definition.json, examples/todo-with-better-auth/baseplate/project-definition.json
Split accounts into accounts/auth and accounts/users features; moved and added module entry files, updated file-id-map and path metadata, adjusted many import paths and model featureRefs; added defaults to many model fields and bumped CLI version in todo example.
Example: Misc. Metadata & Imports
examples/blog-with-auth/apps/admin/.paths-metadata.json, examples/blog-with-auth/apps/backend/.paths-metadata.json, examples/blog-with-auth/apps/backend/src/constants/queues.constants.ts, various apps/backend/src/... files
Updated .paths-metadata entries, adjusted queue import paths, and updated numerous internal imports to reflect the new auth/users layout.
Changesets
.changeset/plugin-schema-issue-checkers.md, .changeset/add-accounts-feature-ref.md
New changeset docs describing registration of plugin schema issue checkers and the accounts/auth/users feature ref migration (migration 029 referenced).

Sequence Diagram

sequenceDiagram
    actor PluginInit as Plugin Initialization
    participant IC as IssueCheckers
    participant SC as SchemaChecker
    participant PD as ProjectDefinition/Container
    participant Diff as Diff Engine
    participant UI as Web UI

    PluginInit->>IC: receive issueCheckers dependency
    PluginInit->>IC: register checker<br/>issueCheckers.checkers.set(pluginKey, checker)

    SC->>PD: load plugin config & plugin definition
    SC->>Diff: diff(current definition, partial definition)
    alt diff found
        Diff-->>SC: diff result (changed labels)
        SC->>IC: emit warning issue with fix action
    else no diff
        Diff-->>SC: no changes
    end

    UI->>IC: list issues
    UI->>SC: previewIssueFix(issue, container)
    SC->>PD: apply fix to draft & serialize before/after
    SC->>Diff: diff(serialized before, serialized after)
    Diff-->>UI: return DefinitionDiff
    UI->>UI: display expandable diff
    UI->>IC: apply fix action
    IC-->>PD: applyMergedDefinition -> update project definition
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main objective: registering definition issue checkers across multiple plugins (auth, rate-limit, storage) for schema validation, which is the primary change throughout the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kingston/eng-1074-show-plugin-schema-merger-errors-in-issues
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 15, 2026

Copy link
Copy Markdown

Deploying baseplate-storybook with  Cloudflare Pages  Cloudflare Pages

Latest commit: 994e60b
Status: ✅  Deploy successful!
Preview URL: https://a783e085.baseplate-storybook.pages.dev
Branch Preview URL: https://kingston-eng-1074-show-plugi.baseplate-storybook.pages.dev

View logs

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/plugin-auth/src/local-auth/core/components/local-auth-definition-editor.tsx (1)

160-161: ⚠️ Potential issue | 🟡 Minor

Fix typographical errors in environment variable names.

The description references INTIIAL_USER_EMAIL and INTIIAL_USER_PASSWORD which should be INITIAL_USER_EMAIL and INITIAL_USER_PASSWORD.

📝 Proposed fix
                     add a seed script to create the initial user provided a
-                    .seed.env exists with the INTIIAL_USER_EMAIL and
-                    INTIIAL_USER_PASSWORD variables.
+                    .seed.env exists with the INITIAL_USER_EMAIL and
+                    INITIAL_USER_PASSWORD variables.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@plugins/plugin-auth/src/local-auth/core/components/local-auth-definition-editor.tsx`
around lines 160 - 161, In the LocalAuthDefinitionEditor component text that
currently mentions ".seed.env exists with the INTIIAL_USER_EMAIL and
INTIIAL_USER_PASSWORD variables", correct the typographical errors by replacing
INTIIAL_USER_EMAIL with INITIAL_USER_EMAIL and INTIIAL_USER_PASSWORD with
INITIAL_USER_PASSWORD so the displayed documentation strings in
local-auth-definition-editor.tsx are accurate.
🧹 Nitpick comments (3)
packages/project-builder-web/src/components/definition-warning-dialog/definition-warning-dialog.tsx (1)

43-44: Consider resetting expandedIndex when warnings change.

When a fix is applied and warnings array updates (lines 61-64), the expandedIndex may reference a stale or invalid warning. This could cause visual glitches if a different warning now occupies that index.

♻️ Proposed fix using useEffect
 const [applyingFixIndex, setApplyingFixIndex] = useState<number | null>(null);
 const [expandedIndex, setExpandedIndex] = useState<number | null>(null);
+
+// Reset expanded index when warnings change
+React.useEffect(() => {
+  setExpandedIndex(null);
+}, [warnings]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/project-builder-web/src/components/definition-warning-dialog/definition-warning-dialog.tsx`
around lines 43 - 44, The expandedIndex state can point to a stale index after
the warnings array changes; add a useEffect that watches the warnings array (and
optionally applyingFixIndex) and resets expandedIndex via setExpandedIndex(null)
whenever warnings change (or when a fix completes) so the UI cannot reference an
invalid warning; locate the expandedIndex/setExpandedIndex declarations and the
component that updates warnings to add this effect.
plugins/plugin-rate-limit/src/rate-limit/core/schema/schema-issue-checker.ts (1)

35-37: Silent catch may mask configuration issues.

The empty catch block silently swallows exceptions from getFeaturePathById. While returning [] is safe, this could hide legitimate configuration errors (e.g., corrupted definition) that would be useful for debugging.

Consider logging or at least distinguishing "feature not found" from unexpected errors if the utility supports it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/plugin-rate-limit/src/rate-limit/core/schema/schema-issue-checker.ts`
around lines 35 - 37, The empty catch in the block that calls getFeaturePathById
silently swallows all errors; change it to catch the error (e) and distinguish a
"not found" case from unexpected errors: if getFeaturePathById explicitly
indicates missing feature return [] as before, otherwise log the unexpected
error (include feature id and error message) via the module logger (or rethrow
if appropriate) before returning []; update the try/catch around
getFeaturePathById in schema-issue-checker.ts to capture and report the error
instead of ignoring it.
packages/ui-components/src/components/ui/button/button.tsx (1)

30-33: Use the exported ButtonProps interface instead of duplicating the type inline.

The function parameter type at lines 30-33 duplicates the ButtonProps interface defined at lines 9-10. Since ButtonPrimitive.Props already includes the render prop, the explicit render property in the inline type is redundant.

♻️ Proposed fix
 function Button({
   className,
   variant,
   size,
   justify,
   ...props
-}: ButtonPrimitive.Props &
-  VariantProps<typeof buttonVariants> & {
-    render?: ButtonPrimitive.Props['render'];
-  }): React.ReactElement {
+}: ButtonProps): React.ReactElement {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ui-components/src/components/ui/button/button.tsx` around lines 30 -
33, Replace the inline union type on the Button component parameter with the
exported ButtonProps interface: use ButtonProps instead of
"ButtonPrimitive.Props & VariantProps<typeof buttonVariants> & { render?:
ButtonPrimitive.Props['render'] }". Remove the redundant explicit render
declaration since ButtonPrimitive.Props already includes it; update the function
signature to accept (props: ButtonProps) and keep using buttonVariants and
ButtonPrimitive where referenced.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@plugins/plugin-auth/src/local-auth/core/components/local-auth-definition-editor.tsx`:
- Around line 160-161: In the LocalAuthDefinitionEditor component text that
currently mentions ".seed.env exists with the INTIIAL_USER_EMAIL and
INTIIAL_USER_PASSWORD variables", correct the typographical errors by replacing
INTIIAL_USER_EMAIL with INITIAL_USER_EMAIL and INTIIAL_USER_PASSWORD with
INITIAL_USER_PASSWORD so the displayed documentation strings in
local-auth-definition-editor.tsx are accurate.

---

Nitpick comments:
In
`@packages/project-builder-web/src/components/definition-warning-dialog/definition-warning-dialog.tsx`:
- Around line 43-44: The expandedIndex state can point to a stale index after
the warnings array changes; add a useEffect that watches the warnings array (and
optionally applyingFixIndex) and resets expandedIndex via setExpandedIndex(null)
whenever warnings change (or when a fix completes) so the UI cannot reference an
invalid warning; locate the expandedIndex/setExpandedIndex declarations and the
component that updates warnings to add this effect.

In `@packages/ui-components/src/components/ui/button/button.tsx`:
- Around line 30-33: Replace the inline union type on the Button component
parameter with the exported ButtonProps interface: use ButtonProps instead of
"ButtonPrimitive.Props & VariantProps<typeof buttonVariants> & { render?:
ButtonPrimitive.Props['render'] }". Remove the redundant explicit render
declaration since ButtonPrimitive.Props already includes it; update the function
signature to accept (props: ButtonProps) and keep using buttonVariants and
ButtonPrimitive where referenced.

In
`@plugins/plugin-rate-limit/src/rate-limit/core/schema/schema-issue-checker.ts`:
- Around line 35-37: The empty catch in the block that calls getFeaturePathById
silently swallows all errors; change it to catch the error (e) and distinguish a
"not found" case from unexpected errors: if getFeaturePathById explicitly
indicates missing feature return [] as before, otherwise log the unexpected
error (include feature id and error message) via the module logger (or rethrow
if appropriate) before returning []; update the try/catch around
getFeaturePathById in schema-issue-checker.ts to capture and report the error
instead of ignoring it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a357ecc8-c5ed-46da-99f5-a6271c09e652

📥 Commits

Reviewing files that changed from the base of the PR and between 72b3939 and ac8a6b7.

⛔ Files ignored due to path filters (9)
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/authorizers/user.authorizer.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/authorizers/user.query-filter.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/index.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/schema/user-role.object-type.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/schema/user.mutations.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/schema/user.object-type.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/schema/user.queries.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/auth/services/user.data-service.ts is excluded by !**/generated/**, !**/generated/**
  • examples/todo-with-better-auth/apps/backend/baseplate/generated/src/modules/accounts/users/index.ts is excluded by !**/generated/**, !**/generated/**
📒 Files selected for processing (28)
  • .changeset/plugin-schema-issue-checkers.md
  • examples/todo-with-better-auth/apps/backend/baseplate/file-id-map.json
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/authorizers/user.authorizer.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/authorizers/user.query-filter.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/index.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/schema/user-role.object-type.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/schema/user.mutations.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/schema/user.object-type.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/schema/user.queries.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/auth/services/user.data-service.ts
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/users/index.ts
  • examples/todo-with-better-auth/baseplate/project-definition.json
  • packages/project-builder-lib/src/parser/definition-issue-utils.ts
  • packages/project-builder-lib/src/parser/index.ts
  • packages/project-builder-lib/src/schema/models/models.ts
  • packages/project-builder-lib/src/web/components/definition-diff-alert.tsx
  • packages/project-builder-web/src/app/project-sync-modal/project-sync-modal.tsx
  • packages/project-builder-web/src/components/definition-warning-dialog/definition-warning-dialog.tsx
  • packages/ui-components/src/components/ui/button/button.tsx
  • plugins/plugin-auth/src/better-auth/core/common.ts
  • plugins/plugin-auth/src/better-auth/core/schema/schema-issue-checker.ts
  • plugins/plugin-auth/src/local-auth/core/common.ts
  • plugins/plugin-auth/src/local-auth/core/components/local-auth-definition-editor.tsx
  • plugins/plugin-auth/src/local-auth/core/schema/schema-issue-checker.ts
  • plugins/plugin-rate-limit/src/rate-limit/core/common.ts
  • plugins/plugin-rate-limit/src/rate-limit/core/schema/schema-issue-checker.ts
  • plugins/plugin-storage/src/storage/core/common.ts
  • plugins/plugin-storage/src/storage/core/schema/schema-issue-checker.ts
💤 Files with no reviewable changes (1)
  • examples/todo-with-better-auth/apps/backend/src/modules/accounts/users/index.ts

@kingston kingston merged commit 37b6d8f into main Mar 19, 2026
12 checks passed
@kingston kingston deleted the kingston/eng-1074-show-plugin-schema-merger-errors-in-issues branch March 19, 2026 14:27
@github-actions github-actions Bot mentioned this pull request Mar 18, 2026
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.

1 participant