Skip to content

Support format=csv on bad_hosts() and the CLI (#16) - #18

Merged
foospidy merged 1 commit into
masterfrom
feature/16-bad-hosts-csv-format
Oct 8, 2026
Merged

foospidy merged 1 commit into
masterfrom
feature/16-bad-hosts-csv-format

Conversation

@foospidy

@foospidy foospidy commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #16.

What changes

  • Client.bad_hosts() takes a keyword-only format argument ("json" default, "csv"; see BAD_HOSTS_FORMATS). With "csv" it returns the API's CSV text as a str, unparsed.
  • honeydb bad-hosts --format csv writes that text to stdout byte for byte (UTF-8, \n endings on every platform). --pretty has no effect on it.
  • mydata and per-service requests are JSON only on the API. The format is ignored there and parsed JSON is returned; no format parameter is sent.
  • An unsupported format raises ValueError before any request (CLI: usage error, exit 2).
  • A CSV request answered with something that is not non-empty UTF-8 text/csv raises HoneyDBError instead of returning it as CSV.
  • Version 2.2.0.

Also changed, outside bad-hosts

  • HoneyDBError now has retry_after for any error that carries a Retry-After header, so the 503 a CSV request can get exposes it. An unparseable header (for example an HTTP-date) gives None; before, a 429 with one let a ValueError escape.
  • The CLI exits quietly with code 1 when its output pipe is closed (honeydb bad-hosts --format csv | head), for every command, instead of printing a traceback.

Not included

  • /bad-hosts-7d and /bad-hosts-daily: the client has no methods for them; left for a follow-up.

Verification

  • ruff format --check, ruff check: clean. pytest: 162 passed (110 existing, unmodified, plus 52 new).
  • Ran the CLI against a local stand-in server serving a 4.4 MB CSV: full output is byte-identical, | head exits without a traceback, --mydata with --format csv prints JSON.
  • Not run against the live API.

Design docs: https://github.com/honeydbio/honeydb-web/pull/426

🤖 Generated with Claude Code

bad_hosts() takes a keyword-only format argument; with "csv" it returns
the API's CSV text unparsed. `honeydb bad-hosts --format csv` writes that
text to stdout byte for byte. mydata and per-service requests are JSON
only, so the format is ignored there and parsed JSON is returned.

Also:
- HoneyDBError carries retry_after for any error with a Retry-After
  header (e.g. the 503 a CSV request can get); an unparseable header
  gives None instead of a ValueError.
- The CLI exits quietly when its output pipe is closed (| head).
- Bump version to 2.2.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@foospidy
foospidy merged commit 4c0adc0 into master Oct 8, 2026
4 checks passed
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.

Support format=csv on bad_hosts() and the CLI

1 participant