Skip to content

fix(ui): harden token costs refresh script - #876

Open
Ghraven wants to merge 1 commit into
apache:mainfrom
Ghraven:fix/token-costs-fetch-output
Open

Ghraven wants to merge 1 commit into
apache:mainfrom
Ghraven:fix/token-costs-fetch-output

Conversation

@Ghraven

@Ghraven Ghraven commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Problem

The token-cost refresh script fetches LiteLLM's model pricing JSON and writes model_costs.json, but the network request can hang indefinitely and HTTP failures are not surfaced explicitly. The generated JSON write also relied on the platform default text encoding.

Before / after

Before:

  • requests.get() used no timeout.
  • HTTP error responses were passed straight to JSON parsing.
  • model_costs.json was written with the default platform encoding.

After:

  • the request has a bounded timeout,
  • HTTP failures raise through raise_for_status(), and
  • the generated JSON is written as UTF-8.

Verification

  • python -m py_compile telemetry/ui/scripts/token_costs.py
  • Ran telemetry/ui/scripts/token_costs.py from a temporary working directory and confirmed it generated model_costs.json
  • git diff --check

@github-actions github-actions Bot added the area/ui Burr UI (telemetry frontend) label Aug 8, 2026

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

area/ui Burr UI (telemetry frontend)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant