Repository navigation
fix(scope): harden error handling; claudescope-py uses Parquet for query() - #29
Merged
Merged
Conversation
…erved, mangled <>& fixed
Three related bugs in CLI error plumbing:
- cli/client.go: DoRequest embedded the daemon's raw JSON error body
verbatim as the error string, so main.go's writeErrorAndExit stuffed
an already-JSON blob into another {"error","code"} envelope. Now
DoRequest decodes the daemon's {error,code} and returns a clean
message via a new APIError type.
- main.go/client.go: that same flattening was previously dropping the
daemon's specific error code (e.g. SESSION_NOT_FOUND) in favor of a
hardcoded COMMAND_FAILED at the top level, since the code lived only
inside the nested JSON blob. APIError now carries Code through to
writeErrorAndExit so callers (including claudescope-py) get the real
code back.
- encoding/json HTML-escapes < > & by default; any error message or
field name containing them came out as <-style garbage. Daemon
responses and all CLI-side json.Marshal call sites now go through
SetEscapeHTML(false), replacing the ad-hoc string-replace workaround
that only covered runHelp's output.
Also: query-multi --format csv/parquet silently dropped the "errors"
list when used with --union true, since row-shaped output has nowhere
to put per-session failures. It now rejects the request instead,
pointing the caller at --format json.
Session.query() now calls the CLI with --format parquet and loads the
result via pd.read_parquet() instead of parsing --format json through
pandas' dict-list constructor. Faster for large results and preserves
native bool/float64/string dtypes rather than relying on JSON type
inference.
query_multi()'s union mode stays on JSON: --format can't carry the
per-session "errors" list alongside row data (see the Go-side fix in
the previous commit), and this wrapper needs both together.
Adds _cli.invoke_bytes() for raw (non-JSON) stdout, used by the new
Parquet path; on a non-zero exit it still decodes the CLI's
{"error","code"} JSON body the same way invoke() does. Also drops
invoke()'s now-dead double-JSON-unwrap workaround, since the daemon
error is no longer double-encoded on the Go side.
Adds pyarrow as a required dependency (needed by pandas to read/write
Parquet).
rylero
force-pushed
the
worktree-cached-spinning-raccoon
branch
from
July 6, 2026 13:36
d423b12 to
e7708d2
Compare
rylero
marked this pull request as ready for review
July 6, 2026 13:36
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.
Summary
{"error","code"}envelope, and</>/&in any error text or field name came out as<-style garbage (encoding/json HTML-escapes by default). Errors are now flat, clean text.SESSION_NOT_FOUND) was only recoverable by unwrapping that nested JSON blob; it's now carried through cleanly via a typedAPIErrorso both the CLI's own JSON output andclaudescope-pyget the real code.query-multi --format csv/parquet --union truedropped the per-sessionerrorslist entirely when some sessions in the batch failed (row-shaped output has no place to put them). Now rejects the request instead, pointing the caller at--format json.claudescope-py'sSession.query()now fetches results as--format parquetinstead of JSON, parsed viapd.read_parquet()— faster for large results and preserves native bool/float64/string dtypes instead of relying on pandas' JSON type inference.query_multi()'s union mode stays on JSON since it needs the per-session errors list alongside the rows.http.Client.Timeout, confirmed via a live test against a black-holed IP.Test plan
go build ./...,go vet ./...,go test ./...all passpytest(16 tests) passes inpython/session.query(), error codes (SESSION_NOT_FOUND) propagate correctly, union-mode errors still surface via JSON,--formatcorrectly rejects a union query with partial failures🤖 Generated with Claude Code