Repository navigation
Conversation
…idget
A query parameter that one provider requires but the route's other
providers don't is made optional on the shared route (force_optional), so
the route accepts requests for the other providers. That also dropped the
requirement from the requiring provider's widget input: a client saw it as
optional, sent nothing, and the request failed validation server-side.
The route stays optional. The requiring provider's json_schema_extra now
carries `x-widget_config: {"optional": false}`, merged under any
x-widget_config the provider declares itself, so its own keys win. Only
query parameters get it; Data fields are untouched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several providers can share a route, and one of them may require a query parameter that the others don't have or keep optional. In that case
_extract_paramsbuilds the route's parameter withforce_optional=True, so requests for the other providers still validate. The requiring provider's widget then loses the requirement too: openbb-platform-api sets a widget input'soptionalfrom the route'srequired, so the input shows as optional for that provider as well. The client sends no value, and the request fails at the provider'sQueryParams./cftc/cot'scodeis one example.Change
The route parameter stays optional. In
_create_field, when a required query parameter is forced optional, the requiring provider'sjson_schema_extragetsx-widget_config: {"optional": false}. Anyx-widget_configthe provider declares itself is merged over it, so the provider's own keys win. openbb-platform-api already applies a provider'sx-widget_configto its widget input. Only query parameters get the flag;Datafields are untouched.Tests
New in
tests/app/test_provider_interface_merge.py:Nonedefault and gets{"cftc": {"x-widget_config": {"optional": False}}};x-widget_configkeys and choices are kept, and its explicitoptionalwins;_extract_params, only the provider that requires the field is marked, and the shared route stays optional;_extract_data, a requiredDatafield gets no widget config.The first and third fail without the change; the other two guard the merge and the query-only scope.
tests/app/test_provider_interface_merge.pyandtests/app/test_provider_interface.pypass 50/50, andopenbb_platform/core/testspasses 2,252 with 16 skipped (Python 3.12).The existing
test_create_field_with_widget_config_extraandtest_create_field_with_choices_and_widget_config_updates_existing_choice_bucketassert an exactx-widget_config, but they need no change. They build non-query fields (query=False), which this change leaves alone.Results from a deployment
OpenBQ's Docker image has run this as a build-time patch over openbb-core 2.0.1, which matches
developfor this file. Our test buildswidgets.jsonwith openbb-platform-api from the full installed app. It walks every_obbwidget's provider-only inputs and found 41 that the provider requires. All 41 are nowoptional: false, and none of the matching OpenAPI parameters became required.This complements #7751, which maps the resulting failure, a missing provider input, to a 422. In a sweep that called every widget, 82 provider-required inputs answered
500 Unexpected Error -> ValidationError, out of 100 500s for that class of request. Together, the two changes mean the widget asks for the input, and a request that still lacks it gets a 422.Not included
QueryParams.Datafields and body parameters are unchanged.🤖 Generated with Claude Code