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 understanding the issue. The problem is that OpenAPI path parameters are being imported as optional when
requiredis omitted, even though path parameters should be required by the OpenAPI specification. I need to find the relevant code that handles OpenAPI v4 imports and fix it to treat path parameters as required regardless of therequiredfield.Let me explore the repository structure first.
Assistant
This looks like a Rust project with a crates directory. Let me explore the crates to find the OpenAPI v4 import functionality.
Assistant
Let me search for OpenAPI-related code and the importer/projection functionality.
Assistant
Let me look at the OpenAPI import file and the IR model for path parameters:
Assistant
The file is quite short. Let me continue reading the rest of this file since it might be truncated, and also look at other relevant files like the operations.rs file which likely contains more import logic.
Assistant
The file is only 124 lines and I've seen it all. The key method is
import_operationwhich isn't shown. Let me look at the operations.rs file:<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rs </tool_call>
Assistant
I forgot to provide the command argument. Let me try again.
Assistant
Now I can see the issue! In the
import_parametersmethod, therequiredfield for parameters is set based on whether therequiredkey exists in the OpenAPI parameter object:rustrequired: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),For path parameters, OpenAPI spec says they are implicitly required, but the current code defaults to
falsewhenrequiredis omitted. Let me look at the IR model and the tests to understand the full context.Assistant
Now let me look at the existing tests for the OpenAPI importer to understand what's expected. Let me also look at the model file:
Assistant
Now I have a good understanding of the codebase. The issue is in
/coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rsin theimport_parametersmethod. The key line is:rustrequired: parameter_obj .get("required") .and_then(Value::as_bool) .unwrap_or(false),This defaults to
falsewhenrequiredis omitted. According to the OpenAPI specification, path parameters are always required even if not explicitly marked as such. So I need to change this logic so that path parameters are treated as required regardless of therequiredfield value.The fix should be:
- If the parameter is a path parameter (
location == OpenApiParameterLocation::Path), always setrequiredtotrue - For non-path parameters, preserve the current behavior (read from
requiredfield or default tofalse)
Let me also check if there are any projection tests I should be aware of.
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/projection_tests.rs </tool_call>
- If the parameter is a path parameter (
Assistant
I need to provide a command argument to run the command.
Assistant
Now let me check the test support module and understand the
github_openapi()fixture:Assistant
Now I have a clear understanding. The issue is in
/coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rsin theimport_parametersmethod. Therequiredfield defaults tofalsewhen not specified, but path parameters should always be required per the OpenAPI spec.Let me first run the existing tests to establish a baseline:
Assistant
Good, all 219 tests pass. Now let me identify the exact location of the fix needed. The problem is in
import_parametersmethod in/coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rswhere therequiredfield defaults tofalsewhen omitted, even for path parameters.Let me now implement the fix:
Assistant
Let me look at the context around line 161 which is the one in the
import_parametersmethod where parameters'requiredfield is set.Assistant
Now I understand the issue. The fix is to change the
requiredfield logic so that path parameters are always treated as required even whenrequiredis omitted. Let me make the fix:Assistant
I need to use the
editcommand properly with the correct format. Let me look at the special command format again.Assistant
The edit was applied. Let me verify the change is correct and run the tests to make sure everything works.
Assistant
I need to see the current state of the file to fix the issue - it seems the edit removed some lines. Let me check:
Assistant
I see the issue - my edit accidentally removed the
locationanddata_typefields. Let me fix this by adding them back:Assistant
Now let me run the tests to verify the fix:
Assistant
All 219 tests pass. Let me verify my change and also check if the acceptance criteria mention adding "focused importer/projection coverage" - I should add a test to ensure path parameters are treated as required even when the
requiredfield is omitted.Assistant
The fix is correct. Now I need to add a focused test to cover the importer/projection behavior for path parameters that are required by default. Let me add a test to the openapi_tests.rs file:
Assistant
Let me look at the end of the openapi_tests.rs file to add a new test:
Assistant
Now let me add a test to verify that path parameters are treated as required even when
requiredis omitted:Assistant
Now let me run the tests to verify my new test passes:
Assistant
Let me fix the type error in the test. The issue is with the map key type:
Assistant
The issue is that the BTreeMap has
&Stringas keys but we're trying to look up with&str. I need to fix the test to use the correct key type. Let me fix it.Assistant
The test file is at lines 668-750 and the issue is with the BTreeMap key type. I need to fix the test to use
Stringkeys instead of&Stringkeys. Let me replace the problematic section of the test.Assistant
The user's command seems to have completed. Let me run the tests again to see if my fixes resolved the compilation errors.
Assistant
The test passes. Let me run all tests to make sure everything still works:
Assistant
All 220 tests pass (219 existing + 1 new test I added). Let me review the complete diff to confirm all changes are correct:
Assistant
Let me run the full test suite to ensure the fix is complete and nothing else is broken:
Assistant
The 2 failing tests (
import_rolls_back_on_config_write_failureanddelete_restores_artifacts_on_cleanup_failure) are unrelated to my changes - they're about file system error handling in test infrastructure. Let me verify these tests were already failing before my changes by checking if they're flaky or environment-specific:Assistant
The test is failing even without my changes (I stashed them), so this is a pre-existing issue unrelated to my fix. Let me restore my changes:
Assistant
My changes are restored. Let me verify the core tests still pass:
Assistant
All 220 tests in coral-spec pass. The 2 failing tests in coral-app are pre-existing failures unrelated to my changes (I confirmed this by reverting my changes and running those tests - they still failed).
Let me review the final changes:
Assistant
The user wants me to submit my changes. I've successfully:
- Fixed the issue in
/coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rswhere path parameters were being imported as optional whenrequiredwas omitted - Added a focused test in
/coral/crates/coral-spec/src/v4/openapi_tests.rsto cover this behavior - All 220 tests in coral-spec pass (the 2 failures in coral-app are pre-existing and unrelated to my changes)
I should submit my changes now.
- Fixed the issue in
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.