Conversation
This comment has been minimized.
This comment has been minimized.
f0da92c to
adffbfb
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nrainhart
left a comment
There was a problem hiding this comment.
Great work! I know this is still a draft, but I couldn't stop myself from leaving a bunch of comments 😅
packages/jazz-tools/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts
Outdated
Show resolved
Hide resolved
packages/jazz-tools/src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts
Outdated
Show resolved
Hide resolved
packages/jazz-tools/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts
Outdated
Show resolved
Hide resolved
packages/jazz-tools/src/tools/implementation/zodSchema/schemaTypes/schemaValidators.ts
Outdated
Show resolved
Hide resolved
packages/jazz-tools/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts
Outdated
Show resolved
Hide resolved
packages/jazz-tools/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts
Show resolved
Hide resolved
...zz-tools/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Are there any other zod constructs we should ignore? E.g. transforms & default values
d5879e1 to
34ac5a2
Compare
|
Rebased with 0.19.22 for pre-release publish |
…ueSchema handling
… in CoList, CoFeed, CoMap, and Account schemas
…ng in CoFeed, CoList, and schemaUnion
…ueSchema retrieval and enhancing return structure
…lueSchemaTransformation
feat: remove legacy coField schema
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
There was a problem hiding this comment.
Union schema detection uses wrong property
High Severity
isUnionSchema checks schema.type === "union" instead of the runtime definition field used elsewhere (schema.def.type). This can make extractFieldShapeFromUnionSchema and extractFieldElementFromUnionSchema reject valid union schemas, which then either disables per-field validation in coMap mutations or throws non-validation errors in coList/coFeed mutations.
Additional Locations (2)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| for (const [from, to, insert] of patches.reverse()) { | ||
| this.splice(from, to - from, ...insert); | ||
| this.spliceLoose(from, to - from, ...insert); |
There was a problem hiding this comment.
CoList diff updates skip validation
Medium Severity
CoList.$jazz.applyDiff now calls spliceLoose, which bypasses runtime schema checks. This makes a write path mutate lists without validation, even when global mode is strict. Invalid data can be written through applyDiff, diverging from the new validation behavior for normal mutators.
| return ResolvedClass.fromRaw(raw); | ||
| } | ||
| } as unknown as SchemaUnionConcreteSubclass<V>; | ||
| } |
There was a problem hiding this comment.
SchemaUnion public factory removed unexpectedly
High Severity
The commit removes SchemaUnion.Of from SchemaUnion and only keeps schemaUnionClassFromDiscriminator as a standalone helper. Existing consumers calling SchemaUnion.Of(...) lose the public API at runtime, which is a breaking behavior change not reflected in the PR’s stated migration scope.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| "jazz-tools": patch | ||
| --- | ||
|
|
||
| Removed the legacy `coField` and `Encoders` exports and completed the runtime schema migration to the new schema descriptors. Apps still using the old schema APIs should migrate to the current `co`/zod based schemas. |
There was a problem hiding this comment.
| return class CoListOf extends CoList<Item> { | ||
| [coField.items] = item; | ||
| }; | ||
| } |
There was a problem hiding this comment.
CoList.of guard was unintentionally removed
Low Severity
CoList no longer overrides static of, so CoList.of() now falls back to Array.of. That path bypasses the prior explicit safeguard and can construct non-initialized CoList instances (or throw cryptic constructor errors), re-exposing an API path that was intentionally blocked.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| createCoreCoMapSchema(augmentedShape, optionDef.catchall), | ||
| ); | ||
|
|
||
| return augmentedSchema.getCoValueClass() as typeof CoMap; |
There was a problem hiding this comment.
Union branch class identity lost
High Severity
When schemaUnionDiscriminatorFor needs dummy keys, it now builds a new class from createCoreCoMapSchema(...) instead of extending the matched branch class. Returned values are no longer instances of the original union option class, so branch-specific methods/prototype checks can silently break after co.discriminatedUnion(...) resolution.
| * class BaseWidget extends CoMap { | ||
| * type = coField.string; | ||
| * } | ||
| * |
There was a problem hiding this comment.
SchemaUnion factory API removed unexpectedly
High Severity
SchemaUnion is still publicly exported, but SchemaUnion.Of(...) was removed and the remaining static methods throw Not implemented. Existing consumers using the exported union API can no longer construct usable union classes, causing runtime failures after upgrade.
Additional Locations (1)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| createCoreCoMapSchema(augmentedShape, optionDef.catchall), | ||
| ); | ||
|
|
||
| return augmentedSchema.getCoValueClass() as typeof CoMap; |
There was a problem hiding this comment.
Union branch class metadata dropped
Medium Severity
When adding dummy fields for co.discriminatedUnion, the discriminator now returns a new class from createCoreCoMapSchema(...) instead of extending the matched option class. This drops option-specific schema metadata like permissions, resolveQuery, and class-level behavior for that branch.
* chore: replaced union with superRefine in schema validation * fixup! chore: replaced union with superRefine in schema validation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


Description
Cursor's summary is almost complete. Although the scope is clear and documented on Linear, here are the known weird behaviours:
Check this conversation too.
console.warnreminds users that the default will be "strict" in the next major release.z.default()now works as expected on writes. They don't work on reads. This is a nice feature, but it can be misunderstood.Still missing
Note
High Risk
Touches core CoValue mutation paths and schema runtime internals; behavior changes (validation, new defaults/warnings, descriptor resolution) can break apps or tests and may surface new runtime errors during writes.
Overview
Introduces runtime schema validation on writes for schema-based CoValues (
CoMap,CoList,CoFeed, plus related built-ins), with a new globalsetDefaultValidationMode()and per-mutationvalidationoption to enforcestrictvsloosebehavior (global default is currentlywarn, logging instead of throwing).CoValue implementations are refactored to source descriptors/validation schemas from attached
coValueSchemaobjects (initialized for built-ins), adding validation plumbing acrosscreate/set/push/splice/applyDiffand updating tests/docs/examples to opt into strict validation. Legacy schema exportscoFieldandEncodersare removed, completing the migration toco/zod-based schema descriptors; better-auth adapter creation paths were adjusted to satisfy the new schema expectations (e.g., initializing_deletedand sessions fields).Written by Cursor Bugbot for commit 507f325. This will update automatically on new commits. Configure here.