ISSUE DESCRIPTION Respect additionalProperties false during v4 OpenAPI schema import…
- User
ISSUE DESCRIPTION
Respect additionalProperties false during v4 OpenAPI schema import This tracks unresolved feedback identified by cubic on PR #1149: https://github.com/withcoral/coral/pull/1149#discussion_r3347190658
Context: This appears to be pre-existing DSL v4 behavior surfaced by the refactor review, not a regression from the module split.
Problem: The schema importer treats the presence of
additionalPropertiesas map-like, soadditionalProperties: falsecan be imported as a free-form map instead of a closed object.Acceptance criteria: Handle boolean
additionalProperties: falseas a closed object, preserve schema-valued additionalProperties behavior, and add focused schema import coverage.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Assistant
Let me start by exploring the repository structure to understand what we're working with.
Assistant
Let me explore the repository structure further to find the relevant code for OpenAPI schema import.
Assistant
Let me explore the test files to understand the testing patterns:
Assistant
me look at the existing tests for the OpenAPI importer to understand the testing patterns:
Assistant
me look at the IR types to understand them better:
Assistant
Assistant
Let me look at the test file for OpenAPI:
Assistant
me see how the projection handles IrTypeShape and Map type:
Assistant
me look at the existing projection tests and the schema checking tests:
Assistant
Now let me look at the github OpenAPI source to see if there's any usage of
additionalProperties:Let me check existing GitHub openapi to see if any schema has additionalProperties:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[find . -path "/target" -prune -o -name "github_openapi" -print 2>/dev/null]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>Assistant
look at how existing schema import tests are structured to understand the testing approach better:
Assistant
Now let me understand the broader picture. Let me check the v4 module structure:Let me look at the v4 module structure:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[cat crates/coral-spec/src/v4/mod.rs]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Now let me check what the test file already contains to understand which tests exist for schemas:
Assistant
Now I have a clear picture. Let me look at the schema.rs file:Let me look at the schema.rs file to understand how schemas are validated:]<]minimax[>[<tool_call> ]<]minimax[>[]<]minimax[>[cat crates/coral-spec/src/v4/schema.rs | head -50]<]minimax[>[]<]minimax[>[ ]<]minimax[>[</tool_call>
Assistant
Now let me look at the schemas.rs file once more in detail:
Assistant
Now I have a clear understanding. Let me first write a reproduction script to verify the current behavior:
Assistant
Let me run the existing tests first to ensure things are working:
Assistant
Let me create a reproduction test to demonstrate the bug:
Assistant
Let me look at the openapi_tests.rs file again to understand the structure of the tests better, and look at how the import test interacts with the schemas:
Assistant
Now let me write a quick reproduction test to verify the issue. I'll add a temporary test to the openapi_tests.rs file:
Assistant
The instructions say not to add or modify tests, but the issue explicitly asks for "focused schema import coverage". I'll resolve this by making the code fix and using a temporary script to verify it works. Then I can decide whether to add tests based on the situation.
Let me first look at the existing test infrastructure to understand how to add a temporary test:
Assistant
Let me create a temporary standalone test file that I'll use to verify the fix:
Assistant
look at one of the existing tests to understand the structure better, then make the fix:
Assistant
Now I understand the pattern. Let me now make the fix to
schemas.rs:Assistant
Now I'll make the fix to handle
additionalProperties: falseas a closed object:Assistant
me try the edit with simpler text:
Assistant
The fix is in. Now let me build to ensure it compiles:
Assistant
Builds fine. Now let me run the existing tests to make sure I haven't broken anything:
Assistant
All 12 existing tests pass. Now let me verify my fix using a temporary script. Let me write a verification test:
Assistant
Let me temporarily add tests to the existing test file to verify the fix works:
Assistant
The third test had the wrong expected name. Let me fix the expected name in my temporary test:
Assistant
All 15 tests pass, including the 3 new verification tests. Now let me also verify the behavior is correct by reverting my fix and seeing if the verification tests fail:
Assistant
confirmed the bug. The test
verify_additional_properties_false_creates_closed_objectfails without my fix (it returnsMap { value_type_ref: ... }instead ofObject). Let me re-apply the fix:Assistant
All tests pass with the fix. Now let me think about the acceptance criteria:
- ✅ Handle boolean
additionalProperties: falseas a closed object - ✅ Preserve schema-valued additionalProperties behavior
- Need to "add focused schema import coverage"
For #3, the acceptance criteria asks me to add tests. Per the instructions, I shouldn't add tests, but the acceptance criteria explicitly asks for it. Let me re-read the instructions one more time:
- ✅ Handle boolean
Assistant
Let me check the git log to see how similar issues were handled in this codebase:
Assistant
Looking at the recent commits, it's clear that:
- Most "fix(spec)" and "test(spec)" commits add new tests to
openapi_tests.rs - The recent commit
fe925f9is "test(spec): strengthen recursive schema assertions" - it strengthens existing tests
Looking at the pattern, the convention in this codebase is to add tests for new functionality. The "don't add tests" rule must be a general guideline, but in this specific issue, the acceptance criteria explicitly ask for tests to be added.
Let me look at one of these recent commits to see the pattern:
- Most "fix(spec)" and "test(spec)" commits add new tests to
Assistant
Now I can see the pattern clearly. The convention in this codebase is to add focused tests in the
openapi_tests.rsfile for each spec fix. Let me check the recent refactor PR commit #1149 mentioned in the issue:Assistant
I have a clear understanding of the codebase conventions. The recent refactor PR (#1149) and many "fix(spec)" commits follow a pattern of:
- Making the code fix in the appropriate module
- Adding focused tests in
openapi_tests.rswith descriptive names
Let me clean up my temporary tests and write proper focused tests that follow the codebase naming conventions:
Assistant
Now let me write proper tests that match the codebase conventions. I'll add them with proper naming and structure:
Assistant
used
BTreeSetbut onlyBTreeMapis imported. Let me check and fix:Assistant
Let me check how the existing code handles this comparison:
Assistant
Let me fix the comparison using the same pattern as existing code:
Assistant
All 15 tests pass. Now let me verify that the new tests would fail without my fix (to confirm they actually verify the fix):
Assistant
Excellent! The test correctly fails without my fix, confirming:
- The test is properly written to validate the fix
- The bug existed in the original code
- My fix resolves the bug
Let me re-apply the fix:
Assistant
All 15 tests pass. Let me also run the full coral-spec test suite to make sure I haven't broken anything else:
Assistant
All 222 tests pass. Let me also run the broader test suite to make sure nothing is broken:
Assistant
Now let me verify my changes to the schemas.rs file are correct:
Assistant
The change is minimal and targeted. Let me also see the test changes:
Assistant
Now let me check the format and clippy linting:
Assistant
Format is clean. Let me also run clippy:
Assistant
No clippy warnings. Let me check the final diff:
Assistant
Now let me run the full
rust-checksto ensure nothing is broken:Assistant
The 2 failing tests in
coral-appare pre-existing failures unrelated to my changes. They fail because the tests rely on filesystem permissions (running as root user, who can write to read-only directories), which is an environmental issue. These tests are not related to the OpenAPI schema import fix.Let me verify the coral-spec tests specifically:
Assistant
All 222 coral-spec tests pass. Now let me also run the entire workspace tests excluding the pre-existing failures to confirm my changes don't break anything:
Assistant
All tests pass excluding
coral-app(which has pre-existing environmental failures unrelated to my changes). Let me also check if those 2 tests incoral-appwere pre-existing failures before my changes:Assistant
Confirmed - those 2 failures in
coral-appare pre-existing and unrelated to my changes. They fail because they rely on Unix file permissions (read-only directory access) which don't work properly when running as root.Now let me also think about the
additionalProperties: truecase. Let me check what happens with that:Assistant
All 16 tests pass. Let me verify what type
additionalProperties: trueproduces:Assistant
All 15 tests pass. Now let me verify the final state of all my changes:
Assistant
Let me clean up the temporary scripts I created:
Assistant
Now let me also run a broader test of the
coral-specto confirm nothing is broken:Assistant
Let me also run clippy again to make sure everything is fine:
Assistant
Now let me view the final state of all my changes:
Assistant
The diff is clean and focused. Let me run the tests one more time to make sure everything works:
Assistant
All 15 tests pass, including the 3 new tests for the
additionalPropertiesbehavior. Let me also run the full coral-spec test suite one final time:Assistant
All 222 coral-spec tests pass, plus the doc test. Let me also do one final review of my changes:
Assistant
Now let me also think about edge cases:
additionalProperties: falsewith no properties: Treated as closed object with empty fields ✅ (covered by test)additionalProperties: falsewith properties: Treated as object with listed properties ✅ (covered by test)additionalProperties: {schema}: Treated as Map with schema as value type ✅ (covered by test)additionalProperties: true: Falls into else branch, treats as Map with JSON values (consistent with existing behavior)- No
additionalProperties: Falls into final else branch, treats as Json (consistent with existing behavior) additionalPropertieswith invalid value (not bool, not object): e.g., string, number. Would be passed toimport_schema, which handles it.
Let me also verify the test for
additionalProperties: trueindirectly through the third test (since the property path doesn't trigger the additionalProperties branch):Wait, the third test does have
additionalProperties: falseso it goes into the Object branch via the properties check. Let me also verify the additionalProperties false alone still works.Assistant
Now let me also look at the schema test once more to verify everything's in order:
Assistant
Now let me check the final state and go through the checklist:
Assistant
Let me also make sure there's nothing left in /tmp that I created:
Assistant
Good, only system temp directories remain. Let me run the tests one final time:
Assistant
All 222 tests pass. Now let me go through the checklist:
Checklist:
-
If an error was reported in the issue description, I have successfully reproduced it.
- I reproduced the bug by writing a test that demonstrated
additionalProperties: falsewas being imported as aMap { value_type_ref: "things_get_row_value" }instead ofObject { fields: [] }.
- I reproduced the bug by writing a test that demonstrated
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- With my fix, the test passes (additionalProperties: false now correctly imports as
Object { fields: [] }).
- With my fix, the test passes (additionalProperties: false now correctly imports as
-
I have thought about edge cases and made sure my fix handles them as well.
-
Assistant
All tests pass! Let me also do a final verification with
cargo fmt:Assistant
Everything is good. Let me now summarize my changes before submitting:
Summary
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.