Skip to content

fix: lite schema validation - #2794

Open
sanny-io wants to merge 8 commits into
zenstackhq:devfrom
sanny-io:fix/lite-validation
Open

fix: lite schema validation#2794
sanny-io wants to merge 8 commits into
zenstackhq:devfrom
sanny-io:fix/lite-validation

Conversation

@sanny-io

@sanny-io sanny-io commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #2793 and #2764

Adds a new @@@lite attribute, which specifies that an attribute should not be stripped when generating lite schemas. All validation attributes, @meta, and @@meta, are decorated with it.

@default and @updatedAt are also decorated with because the frontend hooks rely on checking them.

The Zod factory test suite now runs against both a full schema and a lite schema.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added lite schema generation that retains supported validation, metadata, and default attributes.
    • Added lite-compatible schema coverage for models, relationships, computed fields, and authorization settings.
  • Tests

    • Expanded schema generation tests to verify supported attributes are retained and unsupported attributes are removed.
    • Added separate full-schema and lite-schema test coverage.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e66e1a85-e81a-4028-acf7-7ab852e4f2da

📥 Commits

Reviewing files that changed from the base of the PR and between 0a915d7 and 08c7298.

📒 Files selected for processing (1)
  • packages/cli/test/ts-schema-gen.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/test/ts-schema-gen.test.ts

📝 Walkthrough

Walkthrough

Lite-compatible attributes now carry @@@lite markers. Lite schema generation filters attributes by those markers. CLI and Zod tests cover filtered output and full and lite schema targets.

Changes

Lite schema attribute preservation

Layer / File(s) Summary
Define lite-compatible attributes
packages/language/res/stdlib.zmodel, packages/language/src/utils.ts
Standard validation, metadata, default, and timestamp attributes now carry @@@lite. isLiteAttribute identifies marked attributes.
Filter generated lite schema attributes
packages/sdk/src/ts-schema-generator.ts
Lite generation filters model, type-definition, and field attributes by isLiteAttribute. Non-lite generation remains unchanged.
Validate filtered schema output
packages/cli/test/ts-schema-gen.test.ts
Tests verify removal of incompatible attributes and preservation of compatible attributes on models, fields, and type definitions.
Generate and run the lite Zod schema
packages/zod/package.json, packages/zod/tsconfig.json, packages/zod/vitest.config.ts, packages/zod/test/factory.test.ts, packages/zod/test/schema/schema-lite.ts
The Zod package generates a lite schema and runs separate full and lite Vitest projects. The test factory selects the schema based on ZENSTACK_TEST_SCHEMA_TARGET.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing validation in lite schemas.
Linked Issues check ✅ Passed The changes preserve marked validation attributes, filter model, field, and typedef attributes, exclude policy attributes, and test lite Zod validation.
Out of Scope Changes check ✅ Passed The changes support lite schema filtering and full/lite Zod test coverage without unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli/test/ts-schema-gen.test.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/zod/package.json`:
- Line 53: Regenerate the root pnpm-lock.yaml after adding `@types/node` to the
package catalog dependency configuration, ensuring the lockfile records the
matching catalog entry and updated resolution. Commit the resulting lockfile
change alongside the package.json update.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8ec1ad57-98dd-498c-906a-3f0d42c7bca6

📥 Commits

Reviewing files that changed from the base of the PR and between 797b5bc and 20711b2.

📒 Files selected for processing (9)
  • packages/cli/test/ts-schema-gen.test.ts
  • packages/language/res/stdlib.zmodel
  • packages/language/src/utils.ts
  • packages/sdk/src/ts-schema-generator.ts
  • packages/zod/package.json
  • packages/zod/test/factory.test.ts
  • packages/zod/test/schema/schema-lite.ts
  • packages/zod/tsconfig.json
  • packages/zod/vitest.config.ts

Comment thread packages/zod/package.json
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.

Lite schema strips @@@validation attributes, breaking createSchemaFactory client validation

1 participant