-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core[patch]: Fix utils.json_schema.dereference_refs (#24335 KeyError: 400 in JSON schema processing) #24337
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
- Modify `_retrieve_ref` function in `json_schema.py` to correctly handle both integer and string components. - Checks if `component` is a digit and if `int(component)` exists in the schema. - If `int(component)` does not exist, falls back to using `component` as a string key. - Ensures the OpenAPI specification is fully interpreted and the agent executes without errors.
0edc5c4
to
573f4c0
Compare
- Add a new test `test_dereference_refs_string_ref` to ensure that string keys are handled properly in JSON schema references. - Adjust the `test_dereference_refs_missing_ref` to reflect the new behavior of `_retrieve_ref`. - Ensure that JSON schema processing can handle string keys without raising unnecessary KeyErrors.
6bfa043
to
1b98a3d
Compare
- Modify `_retrieve_ref` function to ensure string keys are handled correctly and not incorrectly converted to integers. - Adjust test cases to ensure correct behavior for both integer and string keys.
636588e
to
388fbbe
Compare
Deployment failed with the following error:
|
ab77815
to
0b60c54
Compare
…JSON schema utility - Deleted logic in `_retrieve_ref` function that handled broken references by returning the original schema. - Adjusted the test `test_dereference_refs_missing_ref` to expect a `KeyError` for broken references.
0b60c54
to
c65f09a
Compare
@@ -18,8 +18,7 @@ def _retrieve_ref(path: str, schema: dict) -> dict: | |||
elif component.isdigit() and int(component) in out: | |||
out = out[int(component)] | |||
else: | |||
# Returning the original schema or a default value if the key is not found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code was added to ensure that the agent runs even if there is a problem with the swagger provided by an external solution. We decided that it was right to remove these reference errors through preprocessing logic before the user applied swagger to the agent, so in this case, we modified the code so that a ValueError was raised and also restored the test code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
… KeyError: 400 in JSON schema processing) (langchain-ai#24337) Description: This PR fixes a KeyError: 400 that occurs in the JSON schema processing within the reduce_openapi_spec function. The _retrieve_ref function in json_schema.py was modified to handle missing components gracefully by continuing to the next component if the current one is not found. This ensures that the OpenAPI specification is fully interpreted and the agent executes without errors. Issue: Fixes issue langchain-ai#24335 Dependencies: No additional dependencies are required for this change. Twitter handle: @lunara_x
Description:
This PR fixes a KeyError: 400 that occurs in the JSON schema processing within the reduce_openapi_spec function. The _retrieve_ref function in json_schema.py was modified to handle missing components gracefully by continuing to the next component if the current one is not found. This ensures that the OpenAPI specification is fully interpreted and the agent executes without errors.
Issue:
Fixes issue #24335
Dependencies:
No additional dependencies are required for this change.
Twitter handle:
@lunara_x