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 then find the relevant code for OpenAPI v4 import.
Assistant
This is a Rust repository. Let me explore the crates directory and look for OpenAPI import code.
Assistant
The relevant directory is
/coral/crates/coral-spec/src/v4/surfaces/openapi/. Let me look at the import file and related files.Assistant
Now let me look at the operations.rs file which likely handles parameter import:
Assistant
I found the relevant code. In
import_parameters, therequiredfield defaults tofalsewhen omitted:required: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),According to the OpenAPI spec, path parameters are always required. Let me look at the
OpenApiParameterLocationenum and the IR model to understand the structure better.Assistant
Let me look at the IR model file to understand
OpenApiParameterLocationandIrOperationInput:Assistant
Now I understand the structure. Let me look at the existing tests to understand the test patterns used for the importer and projection coverage:
Assistant
Now let me look at the projection tests and projections to understand how
requiredaffects the projection (the issue mentions "misclassify required path inputs as optional SQL filters"):Assistant
Now let me look at the projections to understand how
requiredaffects SQL exposure. Let me check the derive.rs and runtime.rs in projections:Assistant
Let me look at the derive.rs to understand how
requiredaffects the SQL exposure classification:Assistant
Now I understand the impact. The
requiredfield affects how projections are classified (Table vs TableFunction) and SQL exposure. Let me write a reproduction script first to confirm the issue. Let me check the test_support.rs to understand how to set up tests:Assistant
Now I have a good understanding. Let me look at the mod.rs to understand the module structure and what's exported:
Assistant
Now let me reproduce the issue. I'll create a test that demonstrates the problem - a path parameter with
requiredomitted should be treated as required but is currently treated as optional:Assistant
Rather than a standalone binary, let me look at how to run the existing tests and add a temporary test to the existing test file. Let me first check the Cargo.toml for the coral-spec crate:
Assistant
Now I understand the structure. Let me run the existing tests first to make sure they pass before my change:
Assistant
All 219 tests pass. Now let me make the fix. The issue is in
import_parametersin operations.rs. The fix is to make path parameters required by default whenrequiredis omitted, while preserving the explicit behavior for non-path parameters.Let me look at the exact lines again:
Assistant
Now I understand the issue clearly. According to the OpenAPI 3.0 spec, path parameters are always required (the
requiredfield MUST betruefor path parameters). The current code defaultsrequiredtofalsewhen omitted, which misclassifies path parameters as optional.Let me make the fix in
operations.rs. The fix: path parameters should always be required (per OpenAPI spec), while non-path parameters preserve their explicitrequiredvalue (defaulting tofalsewhen omitted):Assistant
Now let me verify the build compiles:
Assistant
The build succeeds. Now let me add focused importer/projection coverage tests. Let me first add a test to the openapi_tests.rs for the importer side. Let me look at the end of the openapi_tests.rs file:
Assistant
Now let me add a focused importer test. I'll add it to the end of the openapi_tests.rs file:
Assistant
Now let me add a projection coverage test to projection_tests.rs. This test verifies that path parameters with omitted
requiredare correctly classified (not misclassified as optional SQL filters) in the projection:Assistant
Now let me run the new tests to confirm they pass:
Assistant
The raw string literal has an issue. Let me look at what was actually written:
Assistant
The content looks correct. Let me check the exact lines around the error more carefully:
Assistant
I see the issue - the closing
"of the raw string got a,right after it (",), which breaks the syntax. The"should close the string and.as_bytes()should follow on the next line. Let me fix both test files. First, let me remove the broken appended tests:Assistant
The original openapi_tests.rs had 666 lines and projection_tests.rs had 308 lines (from the cat output earlier, it ended around line 308). Let me remove the appended tests by truncating back to the original line counts:
Assistant
Let me verify the files are back to their original state by checking the last lines:
Assistant
The projection_tests.rs has a stray
#[test]at the end. Let me check the original via git:Assistant
The original projection_tests.rs had 306 lines, not 308. Let me restore it properly from git:
Assistant
Good. Now the openapi_tests.rs is at 666 lines (original) and projection_tests.rs is restored. Now let me add the tests using the
editcommand instead of heredoc, which is more reliable. Let me open the openapi_tests.rs and add the test at the end:Assistant
Now I understand the exact pattern. Let me append the test after line 666 using the edit command:
Assistant
The openapi_tests.rs test looks good. Now let me add the projection test to projection_tests.rs:
Assistant
Both tests are added. Now let me run the new tests to confirm they pass:
Assistant
Both new tests pass. Now let me verify the fix actually addresses the issue by temporarily reverting the fix and confirming the new tests fail. Let me first confirm the tests fail without the fix:
Assistant
The tests correctly fail without the fix (reproducing the issue: path params
ownerandrepoarefalsewhenrequiredis omitted) and pass with the fix. Now let me run the full test suite to make sure nothing is broken:Assistant
All 221 tests pass (219 original + 2 new). Now let me check if there are other places in the codebase that might be affected. Let me check if there are other importers or code that handles OpenAPI parameters with the same
requireddefaulting logic:Assistant
No other places use the same pattern. Let me run clippy to ensure the code is clean:
Assistant
No clippy warnings. Let me also run the broader test suite to make sure dependent crates still work (since other crates use the coral-spec projections):
Assistant
Let me also run the coral-app tests since it depends on the spec projections:
Assistant
Two tests failed in coral-app. Let me check if these are pre-existing failures by stashing my changes and running them:
Assistant
This failure is pre-existing (it fails even without my changes - it's an environment/filesystem issue where cleanup doesn't fail as expected when running as root). Let me verify the other failing test is also pre-existing:
Assistant
Both failures are pre-existing and environment-specific (they expect filesystem permission failures that don't occur when running as root). They're unrelated to my change.
Let me check if there are any snapshot/golden files or other test fixtures that might be affected by the change. Let me search for OpenAPI fixtures with path parameters that omit
required:Assistant
The only path parameters that omit
requiredare in my new tests. Let me also check the sources directory and any test fixtures for OpenAPI documents:Assistant
Let me check the cli_e2e test that uses OpenAPI to ensure it's not affected:
Assistant
No path parameters in cli_e2e.rs. Let me run the cli e2e tests to confirm they still pass:
Assistant
All CLI tests pass. Let me now review the final diff of my changes:
Assistant
The diff looks clean. Let me think about edge cases and verify there are no tests elsewhere that rely on path parameters with explicit
required: false:Assistant
No tests rely on path parameters with explicit
required: false. Let me run the complete coral-spec test suite one final time to confirm everything passes:Assistant
All tests pass. Let me also run the coral-mcp tests since they may use the spec projections:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.