Skip to content
TheChatArchiveThe Chat Archive
QwenQwen/Qwen3.6-27B· alibabaHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Treat OpenAPI path parameters as required in v4 import This tracks…

  1. 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 required is 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 required field, preserve explicit behavior for non-path parameters, and add focused importer/projection coverage.

    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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /coral, current file: none) bash-$

  2. Qwen Assistant

    Let me start by understanding the issue. The problem is that OpenAPI path parameters are being imported as optional when the required field is omitted, even though OpenAPI spec says path parameters are always required. I need to:

    1. First explore the repository structure to understand the codebase
    2. Find the relevant code for importing OpenAPI specs
    3. Understand how path parameters are currently handled
    4. Fix the code to treat path parameters as required
    5. Add tests for the fix

    Let me start by exploring the repository.

  3. Qwen Assistant

    Good, I can see this is a Rust project. The relevant files seem to be in /coral/crates/coral-spec/src/v4/surfaces/openapi/. Let me look at the import.rs file first since that's likely where the OpenAPI parameters are imported.

  4. Qwen Assistant

    Let me also look at the operations.rs file where parameters are likely being processed:

  5. Qwen Assistant

    Now I can see the issue. In the import_parameters function, around line 146-148, the required field is determined by:

    required: parameter_obj
        .get("required")
        .and_then(Value::as_bool)
        .unwrap_or(false),
    

    This means if required is omitted, it defaults to false. However, according to the OpenAPI spec, path parameters are always required. So when location is OpenApiParameterLocation::Path, the required should be true regardless of whether the required field is present.

    Let me also look at the existing tests to understand the test patterns:

  6. Qwen Assistant

    Now let me see the projection_tests.rs file to understand the projection testing patterns:

  7. Qwen Assistant

    Now let me also check the test_support.rs file to see the github_openapi fixture:

  8. Qwen Assistant

    Now I understand the issue and the codebase structure. Let me also look at the IrOperationInput struct definition and related types:

  9. Qwen Assistant

    Now I have a clear understanding of the issue. The fix is in the import_parameters function in operations.rs. When the parameter location is path, the required field should default to true instead of false.

    Let me first create a test script to reproduce the issue:

  10. Qwen Assistant

    Good, all tests pass. Now let me create a test script to confirm the issue - path parameters without required: true are being treated as optional:

  11. Qwen Assistant

    Let me run the tests in a simpler way using cargo test:

  12. Qwen Assistant

    Let me look at lines 155-165 more carefully to understand the exact code I need to modify:

  13. Qwen Assistant

    Now I understand the issue. The code on lines 158-161 sets required to false by default when the required field is omitted:

    required: parameter_obj
        .get("required")
        .and_then(Value::as_bool)
        .unwrap_or(false),
    

    But according to the OpenAPI spec, path parameters are always required (see OpenAPI 3.0 spec: "When in is path, the required property MUST be true"). So the fix should be:

    • If location is OpenApiParameterLocation::Path, default required to true
    • For other locations, preserve the current behavior (default to false)

    Let me make the fix:

  14. Qwen Assistant

    Now I'll make the fix. The key change is in lines 158-161 where the required field is determined. I need to change the default from false to true when the location is Path:

  15. Qwen Assistant

    The sed command duplicated the lines. Let me restore the file and make the edit properly:

  16. Qwen Assistant

    Now let me make the edit properly using the edit command:

  17. Qwen Assistant

    The fix is now in place. Let me verify the code compiles:

  18. Qwen Assistant

    The code compiles. Now let me run the existing tests to make sure I haven't broken anything:

  19. Qwen Assistant

    All 219 tests pass. Now let me add focused tests for the fix. According to the acceptance criteria, I need to:

    1. Add importer tests to verify path parameters are treated as required when required field is omitted
    2. Preserve explicit behavior for non-path parameters
    3. Add projection coverage

    Let me look at how to add tests in the openapi_tests.rs file:

  20. Qwen Assistant

    Now let me add the new tests. I'll add tests for:

    1. Path parameters without explicit required should be treated as required
    2. Path parameters with explicit required: true should still work
    3. Non-path parameters should preserve their existing behavior (optional when required is omitted)
    4. A projection test to verify path parameters produce the right SQL exposure
  21. Qwen Assistant

    Now I need to add the import for OpenApiParameterLocation at the top of the test file:

  22. Qwen Assistant

    The test file uses use super::*; which should bring in everything from the parent module. Let me check what's exported from the v4 module:

  23. Qwen Assistant

    Good, OpenApiParameterLocation is re-exported in the v4 module. Now let me run the new tests:

  24. Qwen Assistant

    All new importer tests pass. Now let me add a projection test to verify that path parameters are correctly handled in projections. Let me first understand how path parameters relate to projections by looking at how SqlInputExposure is determined:

  25. Qwen Assistant

    I see that path parameters are mapped to the default_exposure (which is SqlInputExposure::Filter for tables). The projection test should verify that path parameters are correctly classified as filters. Let me add a projection test:

  26. Qwen Assistant

    Now let me run all tests to make sure everything passes:

  27. Qwen Assistant

    All 224 tests pass. Let me also run the full test suite for the entire workspace to make sure my changes don't break anything else:

  28. Qwen Assistant

    The two failing tests are in a different crate (coral-app) and seem unrelated to my changes. They appear to be pre-existing test failures related to file system operations (config write failure, manifest cleanup). Let me verify by checking if these tests fail even without my changes:

  29. Qwen Assistant

    The test also fails without my changes, confirming these are pre-existing failures unrelated to my fix. Let me restore my changes:

  30. Qwen Assistant

    Let me verify all my changes look correct:

  31. Qwen Assistant

    All the changes look correct. Let me run the coral-spec tests one more time to confirm everything passes:

  32. Qwen Assistant

    All 224 tests pass. Let me summarize what I did and verify against the checklist:

    Summary of Changes

    Problem

    OpenAPI path parameters were being imported as optional when the required field was omitted in the OpenAPI spec, even though path parameters are always required by the OpenAPI specification.

    Fix

    Modified /coral/crates/coral-spec/src/v4/surfaces/openapi/operations.rs to treat path parameters as required when the required field is omitted. The change was on line 161:

    Before:

    .unwrap_or(false),
    

    After:

    .unwrap_or(location == OpenApiParameterLocation::Path),
    

    This ensures:

    • Path parameters without explicit required are treated as required (per OpenAPI spec)
    • Path parameters with explicit required: true continue to work correctly
    • Non-path parameters (query, header, cookie) preserve their existing behavior (optional when required is omitted, required when explicitly set to true)

    Tests Added

    1. Importer tests in openapi_tests.rs:

      • importer_treats_path_parameters_as_required_when_required_field_omitted - verifies path params are required
      • importer_preserves_explicit_required_for_path_parameters - verifies explicit required: true still works
      • importer_preserves_optional_query_parameters_when_required_omitted - verifies query/header params remain optional
      • importer_treats_mixed_path_and_query_parameters_correctly - verifies mixed parameter handling
    2. Projection test in projection_tests.rs:

      • projection_treats_path_parameters_as_required_filters - verifies path parameters produce correct SQL exposure (Filter)

    Checklist

    1. If an error was reported in the issue description, I have successfully reproduced it.

      • The issue described that path parameters were imported as optional when required is omitted. I confirmed this by analyzing the code - the import_parameters function was using .unwrap_or(false) which defaults all parameters to optional when required is not specified.
    2. If an error was reported in the issue description, I have confirmed that my fix resolves the error.

      • I changed the default behavior to .unwrap_or(location == OpenApiParameterLocation::Path), which makes path parameters required by default. All new tests pass confirming the fix works correctly.
    3. I have thought about edge cases and made sure my fix handles them as well.

      • Edge cases covered:
        • Path parameters with explicit required: true (still works)
        • Path parameters without required field (now required)
        • Query parameters without required (still optional)
        • Query parameters with explicit required: true (still required)
        • Header parameters without required (still optional)
        • Mixed path and query parameters in the same operation
    4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.

      • All 224 tests in coral-spec pass. The two failing tests in coral-app are pre-existing failures unrelated to my changes (confirmed by testing without my changes).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.