Repository navigation
Support format=csv on bad_hosts() and the CLI (#16) - #18
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16.
What changes
Client.bad_hosts()takes a keyword-onlyformatargument ("json"default,"csv"; seeBAD_HOSTS_FORMATS). With"csv"it returns the API's CSV text as astr, unparsed.honeydb bad-hosts --format csvwrites that text to stdout byte for byte (UTF-8,\nendings on every platform).--prettyhas no effect on it.mydataand per-service requests are JSON only on the API. The format is ignored there and parsed JSON is returned; noformatparameter is sent.formatraisesValueErrorbefore any request (CLI: usage error, exit 2).text/csvraisesHoneyDBErrorinstead of returning it as CSV.Also changed, outside bad-hosts
HoneyDBErrornow hasretry_afterfor any error that carries aRetry-Afterheader, so the 503 a CSV request can get exposes it. An unparseable header (for example an HTTP-date) givesNone; before, a 429 with one let aValueErrorescape.honeydb bad-hosts --format csv | head), for every command, instead of printing a traceback.Not included
/bad-hosts-7dand/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).| headexits without a traceback,--mydatawith--format csvprints JSON.Design docs: https://github.com/honeydbio/honeydb-web/pull/426
🤖 Generated with Claude Code