Skip to content

fix(errors): handle non-numeric API statuses - #1812

Open
weivwang wants to merge 1 commit into
langfuse:mainfrom
weivwang:fix/non-numeric-api-status
Open

fix(errors): handle non-numeric API statuses#1812
weivwang wants to merge 1 commit into
langfuse:mainfrom
weivwang:fix/non-numeric-api-status

Conversation

@weivwang

@weivwang weivwang commented Aug 12, 2026

Copy link
Copy Markdown

What

Prevent error-message generation from raising ValueError when an API error contains a non-numeric status such as "failed". Non-numeric values now use the existing generic response, while integer and numeric-string status handling remains unchanged.

Why

APIError.status accepts both int and str, but the formatter converted every string with int(status). Transport or upstream failures can carry descriptive string statuses, causing the formatter to mask the original API failure with a conversion exception. Batch errors had the same behavior.

Validation

  • uv run --frozen pytest tests/unit/test_error_parsing.py -q (11 passed)
  • uv run --frozen pytest -n auto --dist worksteal tests/unit -q -o log_cli=false --tb=short --disable-warnings with placeholder test credentials (687 passed, 2 skipped)
  • uv run --frozen ruff check langfuse tests
  • uv run --frozen ruff format --check langfuse tests
  • uv run --frozen mypy langfuse

Greptile Summary

The PR prevents error formatting from masking API failures when a status is non-numeric.

  • Centralizes integer and numeric-string status lookup in _error_response_for_status.
  • Falls back to the existing generic response for non-numeric strings.
  • Adds coverage for single and batched API errors.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The helper preserves integer and numeric-string mappings, safely handles non-numeric strings, and is covered for both single and batched errors.

Reviews (1): Last reviewed commit: "fix(errors): handle non-numeric API stat..." | Re-trigger Greptile

Context used:

@CLAassistant

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@weivwang
weivwang marked this pull request as ready for review August 13, 2026 07:27

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

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.

2 participants