Skip to content

fix(core): mark required provider-only query params required in the widget - #7752

Open
artcashin wants to merge 1 commit into
openbq-org:developfrom
artcashin:fix/core-required-provider-widget-inputs
Open

artcashin wants to merge 1 commit into
openbq-org:developfrom
artcashin:fix/core-required-provider-widget-inputs

Conversation

@artcashin

@artcashin artcashin commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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_params builds the route's parameter with force_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's optional from the route's required, so the input shows as optional for that provider as well. The client sends no value, and the request fails at the provider's QueryParams. /cftc/cot's code is one example.

Change

The route parameter stays optional. In _create_field, when a required query parameter is forced optional, the requiring provider's json_schema_extra gets x-widget_config: {"optional": false}. Any x-widget_config the provider declares itself is merged over it, so the provider's own keys win. openbb-platform-api already applies a provider's x-widget_config to its widget input. Only query parameters get the flag; Data fields are untouched.

Tests

New in tests/app/test_provider_interface_merge.py:

  • a required provider-only query parameter keeps a None default and gets {"cftc": {"x-widget_config": {"optional": False}}};
  • a provider's own x-widget_config keys and choices are kept, and its explicit optional wins;
  • with _extract_params, only the provider that requires the field is marked, and the shared route stays optional;
  • with _extract_data, a required Data field 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.py and tests/app/test_provider_interface.py pass 50/50, and openbb_platform/core/tests passes 2,252 with 16 skipped (Python 3.12).

The existing test_create_field_with_widget_config_extra and test_create_field_with_choices_and_widget_config_updates_existing_choice_bucket assert an exact x-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 develop for this file. Our test builds widgets.json with openbb-platform-api from the full installed app. It walks every _obb widget's provider-only inputs and found 41 that the provider requires. All 41 are now optional: 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

  • No change to how routes validate; a missing input is still caught by the provider's QueryParams.
  • Data fields and body parameters are unchanged.

🤖 Generated with Claude Code

…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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant