-
Notifications
You must be signed in to change notification settings - Fork 0
Issue #102: reject invalid discriminators at compile time with clear error and use purely stack based runtime #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…error and use purely stack based runtime This commit addresses issue #102 by implementing comprehensive discriminator validation with the following improvements: **Compile-time Discriminator Validation (RFC 8927 §2.2.8):** - Enforce that discriminator mapping values must be PropertiesSchema (not EmptySchema) - Prevent nullable discriminator mappings with clear error messages - Validate that discriminator keys are not redefined in mapping schema properties/optionalProperties - Provide detailed error messages with actual values and schema context **Stack-based Runtime Validation:** - Refactored EnumSchema and TypeSchema to use validateWithFrame exclusively - Moved validation logic from direct validate() methods to frame-based approach - Enhanced error messages with offset and path information - Maintained backward compatibility through delegation patterns **Key Improvements:** - Fixed property test generation to avoid discriminator key conflicts - Updated manual tests to comply with RFC 8927 discriminator constraints - All validation now uses the iterative stack-based approach - Clear, descriptive error messages for all discriminator violations **Test Results:** - All 96 tests passing including property-based tests with 1000 generated cases - Full RFC 8927 compliance test suite passing - Integration tests with official JTD Test Suite passing This implementation ensures discriminators are validated at compile time with clear error messages and uses the purely stack-based runtime approach as requested in issue #102. Closes #102 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #102 by implementing comprehensive discriminator validation with compile-time enforcement and purely stack-based runtime validation. The changes ensure that invalid discriminators are rejected at compile time with clear error messages, while all runtime validation uses an iterative stack-based approach for consistency and performance.
- Implemented compile-time discriminator validation per RFC 8927 §2.2.8 requirements
- Refactored EnumSchema and TypeSchema to use purely stack-based validation
- Enhanced test suites with property-based test improvements and new compilation tests
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| TestValidationErrors.java | Updated error message format for unknown type validation |
| TestRfc8927.java | Removed discriminator key redefinitions to comply with RFC 8927 |
| JtdSpecIT.java | Removed invalid schema tests that are now handled by separate compiler tests |
| JtdPropertyTest.java | Fixed property test generation to avoid discriminator conflicts and improved error reporting |
| CompilerTest.java | New comprehensive test suite for compile-time discriminator validation |
| CompilerSpecIT.java | New integration test suite for official JTD invalid schema tests |
| JtdSchema.java | Refactored TypeSchema and EnumSchema to use stack-based validation exclusively |
| Jtd.java | Enhanced compiler with discriminator validation and better error handling |
| README.md | Added documentation for discriminator constraints |
| ARCHITECTURE.md | Enhanced architecture documentation with single-path validation details |
| PLAN.md | Added comprehensive project plan documentation |
| AGENTS.md | Enhanced error message standards and guidance |
| ci.yml | Updated expected test count to reflect new test additions |
json-java21-jtd/src/test/java/json/java21/jtd/JtdPropertyTest.java
Outdated
Show resolved
Hide resolved
json-java21-jtd/src/test/java/json/java21/jtd/JtdPropertyTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
Summary
This PR addresses issue #102 by implementing comprehensive discriminator validation with compile-time enforcement and purely stack-based runtime validation.
Key Changes
Compile-time Discriminator Validation (RFC 8927 §2.2.8)
Stack-based Runtime Validation
Test Improvements
Test Results
Implementation Details
The implementation ensures that:
This addresses the core requirements in issue #102 to tighten compile-time schema checks and rely exclusively on the stack validator for discriminators.
Closes #102