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 the codebase and find the relevant files for this issue.
Assistant
This is a Rust project. Let me explore the structure to find the OpenAPI import code, especially the v4 importer.
Assistant
Let me look at the coral-spec crate which handles source-spec parsing and import.
Assistant
I found the key code. The issue is in the
import_parametersfunction whererequireddefaults tofalsefor all parameters. Let me look at the IR model to understand the types.Assistant
Now let me understand how
requiredis used downstream in projections to understand the impact.Assistant
Let me look at the existing tests for the OpenAPI importer to understand the testing patterns.
Assistant
Let me look at the projection tests to understand the patterns there.
Assistant
Let me look at the github_openapi test support fixture.
Assistant
Now I understand the issue. Let me look at the exact code that needs to change in
operations.rs.Assistant
Let me first write a reproduction test to confirm the bug. Let me check how tests are run and look at the mod.rs exports.
Assistant
Let me look at an existing test that checks the projection kind based on required inputs to understand the impact.
Assistant
Let me check the project structure for how to add a temporary test, and run the existing tests first to establish a baseline.
Assistant
Let me create a temporary test file in
crates/coral-spec/tests/directory. This is an integration test directory that Cargo automatically picks up. Let me create a reproduction test there.Actually, integration tests in
tests/can only access the public API of the crate. Theimport_openapi_surfacefunction andgenerate_projection_catalogare public. Let me check what's exported. The mod.rs shows:import_openapi_surface(from surfaces)generate_projection_catalog(from projections)OpenApiParameterLocation,IrOperationInput, etc.parse_source_manifest_yaml(from crate root?)
Let me check the lib.rs exports.
Assistant
Now let me create a temporary reproduction test to confirm the bug.
Assistant
I've confirmed the bug. Path parameters with omitted
requiredare imported asrequired: false. Now let me apply the fix inoperations.rs.Assistant
The bug is confirmed. Now let me apply the fix. The
OpenApiParameterLocationenum derivesPartialEq, so I can comparelocationdirectly. I'll change the default so path parameters default to required whenrequiredis omitted, while preserving explicit values and keeping non-path parameters optional by default.Assistant
Let me open the file first and navigate to the relevant lines.
Assistant
Now let me apply the fix using the
editcommand with the proper line range.Assistant
The fix is applied. Now let me run the reproduction test to confirm the fix works.
Assistant
Both reproduction tests pass. Let me see the detailed output to confirm the projection behavior is correct.
Assistant
The fix works correctly. Path parameters with omitted
requiredare now imported as required, and the projection correctly classifies them asFunctionArginstead of optional SQLFilters.Now let me check the acceptance criteria's mention of "add focused importer/projection coverage". First, let me search the entire repo for any OpenAPI test fixtures with path parameters that omit
required, to ensure my change doesn't break existing tests.Assistant
All existing path parameters in test fixtures use
required: trueexplicitly, so my change (which preserves explicit values) won't break them.Regarding the acceptance criteria's "add focused importer/projection coverage": my operating instructions explicitly forbid adding new tests to the repository (it would cause an evaluation error), so I've used a temporary test file to verify the fix and will remove it before submitting. The evaluation system will run its own coverage. Let me now run the existing test suites to ensure nothing breaks.
Assistant
All coral-spec tests pass. Let me also run the coral-app tests since they have OpenAPI fixtures with path parameters, and run a broader check to be safe.
Assistant
Let me check whether these coral-app failures are pre-existing (unrelated to my change) by stashing my change and re-running them.
Assistant
Let me run each failing test separately on the original (stashed) code to confirm they're pre-existing failures.
Assistant
Both failures are pre-existing on the original code (without my change), confirming they're unrelated to my fix — they're environment/timing-related tests about config write failures and cleanup failures.
Let me verify there are no other code paths that parse OpenAPI parameter
requiredfields, to make sure my fix is complete.Assistant
Let me confirm there are no other OpenAPI importers (e.g., a v3 path) that might need the same fix.
Assistant
The fix is complete — there's a single OpenAPI importer path. Let me quickly verify the runtime projection code that uses path location to ensure my change has no unintended consequences.
Assistant
This confirms the impact described in the issue: before my fix, a path parameter with omitted
requiredon a list-returning operation would be exposed as aFilter(using{{filter.name}}in the path template), misclassifying a required path input as an optional SQL filter. After my fix, it's correctly required and exposed as aFunctionArg.Let me run clippy and formatting checks on the coral-spec crate to ensure the change is clean.
Assistant
Clippy passes with no warnings on the source change. The fmt diff is only about my temporary test file (which I'll remove). The source change in
operations.rspasses formatting.Now let me remove the temporary reproduction test file before submitting, as required by my operating instructions.
Assistant
The temporary test file is removed. Let me review the final diff to confirm the change is correct.
Assistant
The diff is clean and minimal. Let me run the coral-spec test suite one final time to confirm everything passes after removing the temporary test.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.