Skip to content

Harden currency response parsing #39

Description

@wilsonfreitas

Context

Currency response parsing assumes Content-Type is present and that HTML error pages contain the expected XPath element. Unexpected server responses can raise KeyError or IndexError instead of project exceptions.

Scope

Make currency response parsing defensive for missing headers, unexpected HTML, malformed CSV, malformed dates, malformed numeric columns, and empty response bodies.

Branching

Create the implementation branch from project-health-hardening and merge the fix back into project-health-hardening before any merge to main.

Acceptance Criteria

  • Missing Content-Type and unexpected HTML raise stable BCBAPIError variants.
  • CSV/date/numeric parsing errors produce clear messages.
  • Sync and async response parsing stay in parity.
  • uv run pytest -m "not integration", Ruff, and mypy pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: currencyCurrency/PTAX scraping and exchange-rate APIpriority: mediumModerate urgency or impacttype: bugBug fix work

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions