ISSUE DESCRIPTION Resolve OpenAPI $ref response objects during DSL v4 import Problem DSL…
- User
ISSUE DESCRIPTION
Resolve OpenAPI $ref response objects during DSL v4 import
Problem
DSL v4 OpenAPI import currently misses valid response objects that are expressed as
$refs.import_responsecallsselect_json_response, andselect_json_responselooks forcontentdirectly on each response object without first resolving$ref.Code references:
crates/coral-spec/src/v4/mod.rs:972crates/coral-spec/src/v4/mod.rs:1290
A valid OpenAPI shape like this is treated as if the operation has no JSON response:
responses: '200': $ref: '#/components/responses/Foo' components: responses: Foo: content: application/json: schema: type: array items: type: objectImpact
The importer falls through to
OutputCardinality::None, which causes otherwise valid read operations to be hidden/dropped from the generated projection catalog. This can make major portions of a real OpenAPI descriptor disappear from DSL v4 sources.Acceptance criteria
- Response
$refs under operation responses are resolved before selecting JSON responses. - Missing or external response refs produce diagnostics consistent with existing schema/parameter ref diagnostics.
- A regression test covers a
200response that references#/components/responses/...and verifies the projection is published.
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. Assistant
Let me start by exploring the repository structure to understand the codebase and then locate the files mentioned in the issue description.
The issue is about DSL v4 OpenAPI import not properly handling response objects that are expressed as
$refs. The key files mentioned are:crates/coral-spec/src/v4/mod.rs:972(import_response)crates/coral-spec/src/v4/mod.rs:1290(select_json_response)
Let me first explore the repository structure and then examine the relevant code.
Assistant
Let me explore the crates directory to find the coral-spec crate and then examine the relevant file.
Assistant
Let me examine the coral-spec crate and specifically the v4 mod.rs file to understand the issue.
Assistant
Let me look at the mod.rs file to understand the structure and find the
import_responseandselect_json_responsefunctions around lines 972 and 1290.Assistant
The mod.rs file is only 54 lines, so the mentioned line numbers (972 and 1290) must be in a different file. Let me search for the import_response and select_json_response functions in the v4 directory.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "import_response|select_json_response" /coral/crates/coral-spec/src/v4/mod.rs </tool_call>
Assistant
Let me try to search for these functions in the v4 directory more broadly.
Assistant
Now I found the files! Let me examine the responses.rs file to understand the issue.
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs </tool_call>
Assistant
I need to use the bash_terminal tool properly with a JSON structure.
Assistant
Now I can see the issue clearly. The
select_json_responsefunction (around line 100) looks forcontentdirectly on the response object, but it doesn't first check if the response object is a$ref. According to the issue:- When a response is a
$reflike$ref: '#/components/responses/Foo', the function should resolve this reference first before looking forcontent. - The current code at line 107 just looks for
contentdirectly without checking for$ref.
Let me look at the imports to understand how the
resolve_reffunction works, and how other parts of the code handle$refresolution.<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/surfaces/openapi/mod.rs </tool_call>
- When a response is a
Assistant
I need to use the bash_terminal tool with proper JSON formatting.
Assistant
Let me look at the import.rs file to understand how resolve_ref works.
Assistant
Now I understand the structure. The
resolve_reffunction is available on theOpenApiImporterstruct. Looking at the code:import_responsecallsselect_json_responseto find the JSON response.select_json_responselooks forcontentdirectly on the response object.- But when a response is a
$ref, the code should first resolve it before looking forcontent.
The fix should be in
select_json_response- it needs to check if the response is a and resolve it before looking for .Assistant
I need to use the bash_terminal tool with proper JSON formatting.
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/openapi_tests.rs </tool_call>
Assistant
Let me try again with the correct format for the bash_terminal tool.
Assistant
Now I understand the testing patterns. Let me also look at the projection tests to understand how tests are structured there.
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/projection_tests.rs </tool_call>
Assistant
Let me try the bash_terminal tool with proper JSON formatting again.
Assistant
Now I understand the codebase. Let me analyze the issue:
select_json_responseinresponses.rslooks forcontentdirectly on response objects- When a response is a
$reflike$ref: '#/components/responses/Foo', the function doesn't resolve the reference first - This causes the importer to miss valid JSON responses
The fix requires modifying
select_json_responseto resolve$refs before looking forcontent. Since this function needs access to the document to resolve references, I'll need to pass the importer (or document) to it.Let me first create a test script to reproduce the issue:
Assistant
Now let me understand the fix needed. The issue is that
select_json_responseneeds to be able to resolve$refs. I'll modify it to accept the importer so it can resolve references.Assistant
Now let me implement the fix. I'll modify
responses.rsto resolve$refs in theselect_json_responsefunction.Assistant
Now let me view the current file to see the exact line numbers and understand the structure better:
<tool_call> <function=bash_terminal> <parameter=command> head -50 /coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs </tool_call>
Assistant
The bash_terminal tool is not working because I'm using incorrect syntax. Let me check the current state.
Assistant
Now I'll edit the
responses.rsfile to fix the issue. The fix involves modifyingselect_json_responseto accept the importer and resolve$refs before looking for content.Assistant
Now let me see the full file to understand the line numbers and the function definitions:
Assistant
Let me see the select_json_response function:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '95,130p' /coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs </tool_call>
Assistant
Let me try to get more context about the select_json_response function to understand exactly what I need to modify.
Assistant
Now I understand the structure. I need to:
- Modify
select_json_responseto take the importer as a parameter - Add logic to resolve
$refs before looking for content - Update the call to
select_json_responseinimport_response
Let me now create the fix by modifying the file:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1,222p' /coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs </tool_call>
- Modify
Assistant
The bash_terminal tool is still not working properly. Let me try a different approach - I'll use the
replacecommand or create a new file directly.Let me try to use the edit command to fix the file:
Assistant
Assistant
It seems like the bash_terminal tool is not working as expected. The error message says "No tool call was invoked" but I did provide a command. Let me try a simpler command first to see if there's an issue with the terminal.
Assistant
The terminal is working, let me try the heredoc command again:
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs | wc -l </tool_call>
Assistant
Let me try a different approach using sed to modify the file:
Assistant
The bash_terminal command is working for simple commands, but the large heredoc might be causing issues. Let me try to use a simpler approach with echo and redirection:
Assistant
Good, basic commands work. Let me try to write the file in smaller chunks or use a different approach. Let me create a Python script to write the fixed file:
Assistant
The file was written successfully. Now let me verify the changes were applied correctly:
Assistant
Let me check that the select_json_response function was updated correctly:
Assistant
Good, the function signature was updated. Let me verify the function content:
Assistant
Now let me verify the rest of the file and check if it compiles:
Assistant
Now let me verify the fix by compiling the code:
Assistant
Let me wait for the build to complete.
Assistant
The compiler is complaining about the lifetime. The issue is that we're trying to return
&'a Valuebut thecandidatesvector owns the values, not references to the original. Let me fix this by changing the return type to not include a lifetime:Actually, looking at the code more carefully, the original return type was
Option<(u16, String, &Value)>where the&Valuewas a reference to the schema inside the response object. After resolving the , we want to get the resolved schema from the target of the , not from the original response.Assistant
Let me fix the compile error by changing the return type to return an owned Value instead of a reference:
Assistant
Now let me try to build again:
Assistant
The build succeeded. Now let me run the existing tests to make sure the fix doesn't break anything:
Assistant
All tests pass. Now let me add a regression test as required by the acceptance criteria to ensure that a response with a
$refis properly handled:Assistant
Now let me add a regression test for response
$refresolution. I'll append a test to the openapi_tests.rs file:Assistant
Now let me run the new tests to verify they pass:
Assistant
The first test passed. Let me also run the other two tests for warning on unresolved and external refs.
Assistant
The tests failed because when a response ref can't be resolved or is external, no diagnostic is generated. I need to modify the code to generate diagnostics for these cases, consistent with how schema/parameter refs are handled. Let me update the implementation:
Assistant
Now let me build and test again.
Assistant
Good, build succeeded. Now let me run all the tests again including the new warning tests.
Assistant
I need to run the tests one at a time or use a filter pattern.
Assistant
The test for unresolved refs passed. Let me run the external ref test:
Assistant
Excellent! Now let me run all the tests to make sure I didn't break anything:
Assistant
All tests pass. Let me also verify that the full repository tests still pass:
Assistant
The 2 failing tests are unrelated to my changes - they're about config write failures and manifest cleanup failures, which are integration tests in
coral-appand not related to the DSL v4 OpenAPI import changes I made. These are likely flaky tests or environmental issues.Let me verify my changes haven't broken anything related to the coral-spec package by running just those tests again, and then also verify the specific issue is fixed by looking at the new tests I added.
Let me now also verify that all the existing OpenAPI tests pass:
<tool_call> <function=bash_terminal> <parameter=command> cd /coral && cargo test --package coral-spec openapi 2>&1 </tool_call>
Assistant
The bash_terminal tool is having issues again. Let me try a simpler command first.
Assistant
Great, all the OpenAPI tests pass. Now let me verify the changes I made by looking at the modified file:
<tool_call> <function=bash_terminal> <parameter=command> cat /coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs | head -120 </tool_call>
Assistant
The bash_terminal tool is having issues with the cat command. Let me try a different approach to view the file.
Assistant
The fix is applied. Let me also check the select_json_response function:
Assistant
Now let me check the rest of the select_json_response function:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '140,155p' /coral/crates/coral-spec/src/v4/surfaces/openapi/responses.rs </tool_call>
Assistant
The bash_terminal tool is having issues. Let me try a simpler approach to verify the fix by checking the git diff to see what was changed.
Assistant
Now let me also check the changes to the test file:
<tool_call> <function=bash_terminal> <parameter=command> cd /coral && git diff crates/coral-spec/src/v4/openapi_tests.rs | head -150 </tool_call>
Assistant
The bash_terminal tool is having issues again. Let me try a simpler git command.
Assistant
The test changes look good. Let me now verify the test file has the expected changes by looking at the added tests:
<tool_call> <function=bash_terminal> <parameter=command> cd /coral && tail -100 crates/coral-spec/src/v4/openapi_tests.rs </tool_call>
Assistant
The bash_terminal tool is having issues with certain commands. Let me try a different approach.
Assistant
The changes look good. Let me check the git status to see all modified files:
Assistant
Good, two files were modified:
crates/coral-spec/src/v4/surfaces/openapi/responses.rs- The fix for response $ref resolutioncrates/coral-spec/src/v4/openapi_tests.rs- The new regression tests
Let me now run a final comprehensive test to make sure everything is working:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.