Conversation
baf0d6e to
738272a
Compare
|
Status Update: All CI checks are now passing, including logic tests for #511 and binary compatibility (MiMa). The solution provides the necessary TypeRegistry support for AST materialization while maintaining backward compatibility through method overloading. Ready for review. |
|
Please can this ticket be reviewed? |
There was a problem hiding this comment.
Pull request overview
This PR enhances ExtensibleMetaSchema.materialize to optionally use a caller-provided Map[TypeId, Schema[_]] registry, improving typed schema reconstruction from ASTs for non-built-in types (Issue #511), and hardens enum DynamicValue decoding.
Changes:
- Added
toSchema(registry: Map[TypeId, Schema[_]])and threadedregistrythroughExtensibleMetaSchema.materializeso Products/Sums can prefer registry schemas safely. - Updated
DynamicValueenum decoding to construct enum cases defensively and surface a meaningfulDecodeErrorwhen construction throws. - Added
Issue511Spectest coverage for registry-based reconstruction, nested products, enums, and “poisoned” registries.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
zio-schema/shared/src/main/scala/zio/schema/meta/ExtensibleMetaSchema.scala |
Adds registry-aware AST materialization and propagates registry through nested schema construction. |
zio-schema/shared/src/main/scala/zio/schema/DynamicValue.scala |
Improves enum decoding by constructing enum values from decoded case payloads and mapping construction failures to DecodeError. |
tests/shared/src/test/scala/zio/schema/Issue511Spec.scala |
Adds regression tests for Issue #511 scenarios including registry prioritization and poisoning fallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
9320d0a to
3c8fde2
Compare
Allows DynamicValue to correctly reconstruct typed records and enums by looking up existing schemas in the provided TypeRegistry during MetaSchema materialization. This ensures recursive and complex types are resolved correctly from their AST representation.
3c8fde2 to
0d189e5
Compare
|
@987Nabil code review suggestions are implemented, please review. |
Description
This PR addresses Issue #511 by enabling
ExtensibleMetaSchema.materializeto utilize an explicitMap[TypeId, Schema[_]]registry. This allows for the successful reconstruction of typed schemas from ASTs even when those types are not part of the standard built-in instances.Key Changes
materializeto prioritize lookups in the provided registry..collect { case ... }pattern inSumandProductcases. This ensures that if the registry contains a type-mismatched schema, the system gracefully falls back to AST-based construction rather than failing or casting incorrectly.DynamicValuereconstruction for enums by wrapping construction inTryto propagate meaningfulDecodeErrors.refsandregistrythrough nested and recursive structures.Verification
Issue511Specwith 5 scenarios:/claim #511