Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging 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.

    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 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. Assistant

    I'll start by exploring the repository to understand the structure and locate relevant files related to OpenAPI import and path parameters. Let me first look at the overall directory.

  3. Assistant

    Let me explore the repository structure more broadly to understand what we're working with.

  4. Assistant

    This is a Rust project (Cargo.toml). The issue is about OpenAPI path parameters being imported as optional. Let me search for OpenAPI-related code.

  5. Assistant

    Let me examine the OpenAPI import code, especially the file related to path parameters.

  6. Assistant

    Let me look at the OpenAPI import code, which is the most relevant file.

  7. Assistant

    Let me look at the operations.rs file which likely handles parameter parsing:

  8. Assistant

    Now I can see the issue. In the import_parameters method, around lines 112-115, there's this code:

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

    This means if the required field is omitted (which is allowed by OpenAPI for path parameters since they are always required), it defaults to false (optional). According to OpenAPI specification, path parameters MUST always be required.

    Let me also look at the existing tests to understand the test structure and find relevant test files.

  9. Assistant

    Let me examine the test files to understand how tests are structured:

  10. Assistant

    Now let me look at the projection_tests.rs to understand how projections handle parameters:

  11. Assistant

    Let me check the IR structure to understand what required field is used for:

  12. Assistant

    Let me find the IrOperationInput struct definition.

  13. Assistant

    Let me examine the IrOperationInput struct.

  14. Assistant

    Now let me check the projection code that uses the required field to determine if a parameter becomes an optional SQL filter. Let me search for that.

  15. Assistant

    Let me find the projection generation code.

  16. Assistant

    Let me check how the required field is used in the projection code.

  17. Assistant

    Now I understand the issue better. Looking at the code:

    1. In operations.rs, when importing parameters, the required field is read from the OpenAPI parameter object. If it's not present, it defaults to false (optional).

    2. According to OpenAPI specification, path parameters are always required. The spec says: "If the parameter location is 'path', this property is REQUIRED and its value MUST be true."

    3. The issue is that when OpenAPI documents omit the required field for path parameters (which is technically valid since it should be true anyway), they're being imported as optional.

    4. This affects how they're used in projections - optional parameters become SQL filters, while required parameters might become function arguments.

    Let me create a test to reproduce the issue. First, let me check if there are existing tests that show this behavior:

  18. Assistant

    Let me look at the test_support.rs to understand the helper functions.

  19. Assistant

    Let me first create a test to reproduce the issue - I'll write a test where a path parameter doesn't have the required field, and verify that it's currently imported as optional. Then I'll fix the code and verify the test passes.

    Let me first check if there's a way to run existing tests to make sure I don't break anything:

  20. Assistant

    The compilation is taking a while. Let me try to run the specific tests to see if they pass first.

  21. Assistant

    Let me check the current directory

  22. Assistant

    Good, I'm already in crates/coral-spec. Let me run tests from here.

  23. Assistant

    Good! All existing tests pass. Now let me create a test to reproduce the issue. I'll write a simple script that creates an OpenAPI document with a path parameter that doesn't have the required field and verify that it's currently imported as optional.

  24. Assistant

    Actually, I should write this as a proper Rust test in the openapi_tests.rs file. Let me do that instead. First, let me understand the existing test structure better by looking at the imports and structure in openapi_tests.rs:

  25. Assistant

    We're in /coral/crates/coral-spec, so the file is at src/v4/openapi_tests.rs

  26. Assistant

    Let me check what's in the super module to understand what's available in tests:

  27. Assistant

    Let me check the exports from surfaces module:

  28. Assistant

    Let me check what's exported from the openapi module:

  29. Assistant

    Good. So import_openapi_surface and generate_projection_catalog are both available via super::* in the test file. Let me now write a proper test in the openapi_tests.rs file.

  30. Assistant

    Let me check the exact line in operations.rs where required is computed:

  31. Assistant

    Let me look at the exact context around line 158 in operations.rs:

  32. Assistant

    Now I understand the exact location of the bug. Lines 158-161 in operations.rs. The fix should be:

    1. If the location is Path, always set required to true (per OpenAPI spec)
    2. Otherwise, use the existing behavior (default to false if omitted)

    Now let me also check how this is used in projections to understand the full impact. Let me look at the projection code that uses input.required:

  33. Assistant

    Let me also check the projection tests to see if there are existing tests for path parameters without required field:

  34. Assistant

    All existing tests have required: true for path parameters. Now let me implement the fix. The fix is simple: in the import_parameters method in operations.rs, when computing the required field, we need to check if the location is Path. If it is, we should set required to true regardless of what the OpenAPI document says.

  35. Assistant

    Let me use the correct syntax for the edit command.

  36. Assistant

    Let me use the edit command properly:

  37. Assistant

    Great! The fix is applied. Now I need to add tests for this behavior. Let me run the existing tests first to make sure they still pass:

  38. Assistant

    Perfect! All existing tests pass. Now I need to add tests for the new behavior. Let me add tests to the openapi_tests.rs file. I need to add:

    1. A test for path parameters without required field (should be imported as required)
    2. A test for path parameters with explicit required: false (should respect explicit false)
    3. A test for query parameters without required field (should remain optional)
    4. A test for projection behavior with path parameters without required field

    Let me first check the end of the openapi_tests.rs file to add the tests:

  39. Assistant

    Now let me add tests to the end of the file. First, let me check what imports are needed. Let me also check if there's a projection test file I should add tests to:

  40. Assistant

    Let me check the imports in projection_tests.rs:

  41. Assistant

    Now let me add tests to the openapi_tests.rs file. I'll add them at the end:

  42. Assistant

    Let me check the end of the file to make sure it's complete:

  43. Assistant

    Good! Now let me also add a projection test. Let me check if there's a projection test file I should add tests to:

  44. Assistant

    I should also add a projection test that verifies that path parameters without required field are treated as required in projections. Let me add that to the projection_tests.rs file:

  45. Assistant

    Let me check what helper function is used for filter specs:

  46. Assistant

    Let me check the imports and see if projection_filter_specs is imported:

  47. Assistant

    Let me check if it's available in the projections module:

  48. Assistant

    Good. Now let me add a projection test at the end of projection_tests.rs. First, let me check what FilterSpec looks like:

  49. Assistant

    Let me check what's imported from the module to see what FilterSpec is:

  50. Assistant

    Good. Now let me add a projection test to the end of projection_tests.rs:

  51. Assistant

    Now let me add a projection test at the end of projection_tests.rs:

  52. Assistant

    I notice there's a missing closing brace. Let me fix that:

  53. Assistant

    I see there's a duplicate line in the projection test. Let me fix that:

  54. Assistant

    I see there's an extra closing brace. Let me fix that:

  55. Assistant

    I need to fix the duplicate }. Let me look at the file more carefully.

  56. Assistant

    I need to fix the duplicate function definition. Let me fix that:

  57. Assistant

    Good! Now let me run the tests to make sure everything passes:

  58. Assistant

    There's an unclosed delimiter in openapi_tests.rs. Let me fix it:

  59. Assistant

    I see the issue - line 665 has assert_eq!(operation.output.cardinality, OutputCardinality::Unknown); but there's no closing brace } after it. The original test was missing the closing brace. Let me fix it:

  60. Assistant

    Good! Now let me run the tests again:

  61. Assistant

    All 223 tests pass. Now let me also check that the new tests I added are being run:

  62. Assistant

    Perfect! All three new tests pass:

    1. importer_treats_path_parameters_without_required_as_required - tests that path parameters without required field are imported as required
    2. importer_respects_explicit_required_false_on_path_parameter - tests that explicit required: false is respected
    3. projection_treats_path_parameter_without_required_as_required - tests that path parameters without required field are treated as required in projections

    Let me also run a test for query parameters to make sure they still work correctly:

  63. Assistant

    Excellent! All tests pass. Now let me also run the openapi tests to make sure everything is working correctly:

  64. Assistant

    Perfect! All tests pass. Now let me clean up the temporary test file I created earlier:

  65. Assistant

    Now let me verify my changes by looking at the diff:

  66. Assistant

    Perfect! The changes look good. Let me also check if there are any other places in the codebase that might need similar changes. Let me search for other places where required is computed from OpenAPI parameters:

  67. Assistant

    Let me try a different approach:

  68. Assistant

    Good! I can see that the only place where required is computed for parameters is in line 158, which I've already fixed. The other place is for request bodies (line 237), which is correct - request bodies can be optional or required.

    Now let me run the full test suite to make sure everything passes:

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