Skip to content

[Bug] Missing provider credential returns HTTP 500 instead of a structured 4xx (breaks Workspace widget validation) #7628

Description

@artcashin

Describe the bug
When a provider credential is not configured, REST API calls to that provider's endpoints return HTTP 500 with the underlying provider message embedded in prose. A missing credential is an expected configuration state (the standard install leaves most provider keys unset), not an internal server error.

This has a concrete downstream cost: OpenBB Workspace's "Connect backend → Validate widgets" flow treats the 500 as a broken backend and refuses to add an otherwise healthy self-hosted openbb-platform-api backend, because widgets for unconfigured providers can never validate.

To Reproduce

  1. OpenBB Platform 4.7.2 with openbb-us-eia installed and eia_api_key unset.
  2. openbb-api --host 127.0.0.1 --port 6900
  3. curl -i "http://127.0.0.1:6900/api/v1/commodity/short_term_energy_outlook?provider=eia"

Response (HTTP 500):

{"detail": "Error fetching data from the EIA API -> API_KEY_MISSING -> No api_key was supplied.  Please register for one at https://www.eia.gov/opendata/register.php"}

Expected behavior
A structured non-5xx response that machines can classify, e.g. HTTP 400 or 424 with:

{"detail": {"code": "missing_credentials", "provider": "eia", "credential": "eia_api_key"}}

That would let clients (including the Workspace widget validator) distinguish "unconfigured provider" from "server fault", and would let openbb-platform-api (which runs in-process and can see credentials) annotate or exclude affected widgets in widgets.json.

Desktop:

  • OS: Debian 12 (python:3.12-slim container, linux/amd64)
  • Python version: 3.12
  • OpenBB Platform version: openbb 4.7.2, openbb-platform-api 1.3.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions