ISSUE DESCRIPTION Treat OpenAPI path parameters as required in v4 import This tracks…
- User
ISSUE DESCRIPTION
Treat OpenAPI path parameters as required in v4 import This tracks unresolved feedback identified by cubic on PR #1149: https://github.com/withcoral/coral/pull/1149#discussion_r3347190640
Context: This appears to be pre-existing DSL v4 behavior surfaced by the refactor review, not a regression from the module split.
Problem: OpenAPI path parameters are imported as optional when
requiredis omitted, even though path parameters are required by OpenAPI. This can misclassify required path inputs as optional SQL filters.Acceptance criteria: Import path parameters as required regardless of an omitted
requiredfield, preserve explicit behavior for non-path parameters, and add focused importer/projection 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
Now I have a good understanding. Let me look at the OpenAPI spec to understand the existing behavior. The issue is:
In the
import_parametersfunction, when buildingIrOperationInput, therequiredfield is determined from:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),For path parameters, OpenAPI requires them to be
required: true. However, ifrequiredis omitted in the OpenAPI document, we currently default tofalse, treating them as optional. We should treat them as required iflocation == Path.Let me first look at the related types and tests.
Assistant
Now let me look at the related IR types to understand the data structures:
Assistant
Now let me look at the test_support module which has the github_openapi fixture:
Assistant
let me look at the projection logic:
Assistant
me look at all the places where
requiredis used to understand the impact:Assistant
Now let me look at the existing tests to understand what they expect:
Assistant
look at the
IrOperationInputand check what tests already exist with paths withoutrequired:Assistant
Now let me look at the operations.rs more carefully to understand the structure:
Assistant
Now let me check the build system and Cargo.toml:
Assistant
Now let me create a script to reproduce the issue first:
Assistant
Now let me create a temporary test script to reproduce the issue:
Assistant
Now let me run the existing tests to see what's passing:
Assistant
create a temporary reproduction script to verify the issue:
Assistant
Let me write a temporary test file directly in the project to reproduce:
Assistant
Let me add it as a module:
Assistant
I've reproduced the issue. Now let me also check what happens with a
required: falsepath parameter to think about edge cases:Assistant
The test ran but didn't show the output. Let me look at the test output more carefully:
Assistant
Now I understand the issue. Let me apply the fix:
Assistant
Now let me apply the fix:
Assistant
Now I can apply the edit:
Assistant
see I accidentally removed the closing brace. Let me fix this:
Assistant
Now let me verify the file compiles:
Assistant
Now let me run the reproduction test to verify the fix:
Assistant
Wait, I need to update my test case to test the omitted case:
Assistant
The fix works correctly:
- Test 1: Path params with omitted
requiredare nowrequired=true✓ - Test 2: Explicit
requiredvalues are preserved for both path and query parameters ✓
Now let me run all existing tests to make sure nothing is broken:
- Test 1: Path params with omitted
Assistant
All 220 tests pass (including my new reproduction test). Let me now run the entire workspace test suite to be thorough:
Assistant
Now let me look at the related tests to add focused coverage. The issue acceptance criteria mentions adding "focused importer/projection coverage":
Assistant
Let me look at the structure of the existing test file to understand where I should add the new tests:
Assistant
Now let me clean up my temporary test and add the actual focused tests:
Assistant
Let me fix the mod.rs to remove the duplicate:
Assistant
me reset the mod.rs and reapply cleanly:
Assistant
Good, the mod.rs is back to original. Now let me look at the existing tests one more time and decide how to add my focused tests:
Assistant
Now let me look at the projection tests file structure to see where I might add focused projection coverage:
Assistant
me look at how projection_input.required is used:
Assistant
Now let me add the focused tests. First, let me add them to the
openapi_tests.rs:Assistant
Now let me add the focused tests at the end of openapi_tests.rs:
Assistant
made a typo in the YAML. Let me fix it:
Assistant
Let me fix the BTreeMap issue by using a tuple as the key:
Assistant
Let me fix the duplicate
}on line 742:Assistant
Now let me run the tests:
Assistant
Excellent! Both new tests pass. Now let me also add a projection-focused test:
Assistant
need to revert the duplicate section. Let me fix the file:
Assistant
There's still a stray
}on line 308. Let me fix it.Assistant
There's still an issue at line 310 - let me fix it:
Assistant
Let me take a different strategy and reset the projection_tests.rs file:
Assistant
Now let me append the new test directly to the file:
Assistant
All 5 projection tests pass, including the new one. Now let me also fix the openapi_tests.rs to use the same cleaner approach. Let me reset that file too and add the tests cleanly:
Assistant
The openapi_tests.rs additions look correct. Let me run the full test suite:
Assistant
All 222 tests pass (was 219, added 3 new tests: 2 in openapi_tests and 1 in projection_tests). Let me also run the entire workspace tests to make sure nothing else is affected:
Assistant
failing tests appear unrelated to my changes (they're about config write failure handling, likely environment-specific). Let me verify by checking what these tests do:
Assistant
tests rely on filesystem permissions which don't work when running as root. They are unrelated to my changes. Let me verify this by checking the test before and after my changes:
Assistant
Confirmed - these tests were already failing before my changes. They're related to running as root. Let me restore my changes:
Assistant
Let me verify my changes are restored and run the coral-spec tests one more time:
Assistant
The change is minimal and focused. Let me also clean up the duplicate
}in openapi_tests.rs that I noticed earlier:Assistant
All 222 tests pass. Let me also do a final review of my changes:
Assistant
Let me also clean up any temp files I may have left behind:
Assistant
Let me also check that my changes don't introduce clippy warnings:
Assistant
No clippy warnings. Let me run the tests one final time to verify everything is in order:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.