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
I'll start by exploring the repository structure to understand the codebase and locate relevant files.
- Assistant
Let me explore the repository structure more broadly.
- Assistant
This is a Rust project. Let me look at the crates directory and search for OpenAPI-related code.
- Assistant
Let me search for OpenAPI-related code in the repository.
- Assistant
Let me look at the OpenAPI import file since that's where the issue is likely to be.
- Assistant
Now let me look at the operations file to understand how parameters are imported.
- Assistant
I found the issue! In the
import_parametersmethod inoperations.rs, line 95-100 shows:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),This defaults to
falsewhen therequiredfield is omitted, but according to OpenAPI specification, path parameters are always required. Let me check the test files to understand the test structure. - Assistant
Let me also look at the projection_tests.rs to understand the projection side:
- Assistant
Let me look at the projection module to understand how
requiredis used for SQL exposure: - Assistant
Let me search for where
requiredis used in projection generation: - Assistant
Let me look at the IR structures and the projection generation code to understand how
requiredis used. - Assistant
Let me look at the IR types and the projection code to understand how
requiredflows into SQL exposure: - Assistant
Let me look at the derive module to understand how
requiredis used in SQL exposure calculation: - Assistant
Let me look at the IR types to see what
requiredfield is used for: - Assistant
Let me find the IR module file
- Assistant
Let me check the IR model to understand the IrOperationInput structure:
- Assistant
Now let me look at how the projection uses the
requiredfield: - Assistant
Let me look at the projection filter specs code to understand how
requiredaffects SQL exposure: - Assistant
Let me check how
requiredaffects the filter specs: - Assistant
Now I understand the issue. The problem is in
operations.rswhere path parameters are being imported. Whenrequiredis omitted, it defaults tofalse, but according to OpenAPI spec, path parameters are always required. This means path parameters are being treated as optional, which affects:- The
requiredfield inIrOperationInput - The
requiredfield inProjectionInput - The
requiredfield inFilterSpec - The nullable column spec
Let me run the existing tests to make sure they pass:
- The
- Assistant
All tests pass. Now let me understand the exact location where the fix needs to be applied. The issue is in the
import_parametersmethod inoperations.rsaround line 95-100: - Assistant
Let me find the correct path.
- Assistant
We need to be in the right directory. Let me check.
- Assistant
Now let me look at the operations file with the correct relative path.
- Assistant
Let me open the file to see the context around line 158.
- Assistant
Now I understand the issue perfectly. The fix needs to be in the
import_parametersmethod inoperations.rsat lines 158-161. Therequiredfield should default totruefor path parameters whenrequiredis omitted. Let me implement the fix: - Assistant
Let me use the correct syntax for the edit command:
- Assistant
Now I need to add tests. Let me look at the existing openapi_tests.rs file and add tests for:
- Path parameters being required even when
requiredis omitted - Non-path parameters preserving explicit
requiredbehavior - Projection coverage (testing that path parameters are required in projections)
- Path parameters being required even when
- Assistant
Let me see the end of the file to understand where to add the new test:
- Assistant
Now let me add the test at the end of the file. I'll add a test that:
- Tests path parameters are required even when
requiredis omitted - Tests non-path parameters default to optional when
requiredis omitted - Tests projection coverage
- Tests path parameters are required even when
- Assistant
Now let me also add a projection coverage test. Let me look at the projection_tests.rs:
- Assistant
Let me see the end of projection_tests.rs to add a new test:
- Assistant
Now let me add a projection coverage test that validates path parameters are required in projections when
requiredis omitted: - Assistant
I see there are duplicate test definitions and a stray
}. Let me fix the projection_tests.rs file: - Assistant
I need to fix the duplicate
}and duplicate test definition. Let me remove the extra}on line 298: - Assistant
I accidentally duplicated the assert line. Let me fix this:
- Assistant
There's still a duplicate
}on line 298 and a duplicate test definition. Let me fix both issues: - Assistant
I see there's still a duplicate assert line and duplicate test definition. Let me look at the full file to understand the structure:
- Assistant
I see the duplicate test definition on lines 375-378. Let me fix this:
- Assistant
I need to fix multiple issues. First, let me remove the duplicate assert line on line 297:
- Assistant
I still have issues. Let me fix the duplicate
}on line 298: - Assistant
Let me check the git diff to see the state of things, and then fix the file properly:
- Assistant
I need to fix two issues: the duplicate assert line and the duplicate
#[test]. Let me fix them: - Assistant
I still see a duplicate
}on line 298. Let me fix it: - Assistant
Let me just use sed to fix these issues directly:
- Assistant
Let me use sed to insert the new test before the last test in the file:
- Assistant
Let me verify the file now:
- Assistant
Good. Now let me verify the openapi_tests.rs file is also correct:
- Assistant
That output seems wrong - it's showing projection_tests.rs but I asked for openapi_tests.rs. Let me check:
- Assistant
That output looks right for openapi_tests.rs. Let me check the full file to make sure it's correct:
- Assistant
Good. Now let me run the tests to make sure they pass:
- Assistant
The openapi tests pass. Now let me run the projection tests:
- Assistant
All tests pass. Now let me run all tests to make sure nothing is broken:
- Assistant
All 222 tests pass (previously 219, now 222 = 219 + 3 new tests: 2 in openapi_tests and 1 in projection_tests). Let me verify the changes I made are correct by looking at the git diff:
- Assistant
Let me also check the full diff to verify my changes are correct:
- Assistant
The diff looks correct. Let me now run the full test suite one more time to make sure everything is good:
- Assistant
These 2 failures are in
coral-appand seem to be pre-existing integration tests unrelated to my change. Let me verify by checking if they were already failing before my change: - Assistant
The 2 failures are pre-existing in the repo (they exist without my changes). Let me verify my changes pass all coral-spec tests:
- Assistant
All 222 tests pass. Now let me go through the checklist:
-
If an error was reported in the issue description, I have successfully reproduced it. ✅
- The issue is about OpenAPI path parameters being imported as optional when
requiredis omitted. I identified the problematic code in operations.rs line 158-161 where.unwrap_or(false)defaults tofalsefor all parameters.
- The issue is about OpenAPI path parameters being imported as optional when
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅
- Changed
.unwrap_or(false)to.unwrap_or(location == OpenApiParameterLocation::Path)which ensures path parameters are required. Tests confirm this works correctly.
- Changed
-
I have thought about edge cases and made sure my fix handles them as well. ✅
- Path parameters: always required (even when
requiredis omitted)
- Path parameters: always required (even when
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.