Skip to content

fix(cli): browse honors network.tor; Tor-down error on stderr; CSV nits (#132) - #133

Open
JordanCoin wants to merge 1 commit into
mainfrom
fix/132-browse-tor-cli-nits
Open

JordanCoin wants to merge 1 commit into
mainfrom
fix/132-browse-tor-cli-nits

Conversation

@JordanCoin

Copy link
Copy Markdown
Owner

Closes #132

What changed

  • openfoia browse follows network.tor from config; --tor / --no-tor override it. When Tor is configured but unreachable it exits non-zero before launching the browser (_check_tor_or_exit), and prints the same stderr route line as the records commands (Opening <url> (via Tor, real IP hidden).). tor_browse.py is unchanged.
  • _check_tor_or_exit: the Tor-down message goes to stderr (no longer pollutes --json / --csv - stdout) and suggests starting Tor or setting network.tor false, not "drop --tor".
  • --csv PATH writes a header-only CSV on "no results" for records search, request list, analyze extract, deadlines list (on-screen message kept), so a stale file is no longer left looking current.
  • records search CSV keeps full USAspending descriptions and rank-mode snippets; the Rich columns now ellipsize on one line instead of slicing the data.

Tests

  • tests/test_security_egress_cli.py: browse route for config on/off x flag override; fail-closed (non-zero, browser not called, message on stderr not stdout).
  • tests/test_records_cli.py: header-only CSV overwrites a stale file; CSV keeps a long description intact.
  • Full suite: 590 passed, 26 skipped, 2 pre-existing TestLLMExtraction failures.

Not in this PR

govinfo / regulations titles (e.name[:80]) and the DocumentCloud highlight ([:120] + "…") are still sliced before the CSV. Same bug, left out to keep the diff small next to #131.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FWQw8DDrDZ2tFzswSSEtce

…ts (#132)

browse now builds its route from config.network.tor via _egress_policy_from,
with --tor/--no-tor as overrides, runs the fail-closed _check_tor_or_exit
gate, and prints the same stderr route line as the records commands.
tor_browse.py is unchanged; it receives the resolved use_tor.

_check_tor_or_exit writes to stderr so --json and --csv - stdout stay clean,
and its hint no longer tells users to "drop --tor".

--csv PATH writes a header-only file on "no results" for records search,
request list, analyze extract and deadlines list, so a stale file from a
previous run is overwritten. records search keeps full usaspending
descriptions and rank snippets in CSV; the Rich columns ellipsize instead.

Closes #132

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWQw8DDrDZ2tFzswSSEtce
@JordanCoin

Copy link
Copy Markdown
Owner Author

Review (Claude opus reviewer, read-only, 2026-11-06): MERGE. Verified: _egress_policy_from falls back to config when the flag is None; with Tor configured and unreachable the browser is never launched; --no-tor prints 'direct, real IP' to stderr; tor_browse rereads the same host/port the check probed. Other _check_tor_or_exit callers' tests still pass since click's output includes stderr; new tests separate the streams. Header-only CSV: analyze extract persists nothing; records search emits exactly one header line on stdout; error path still exits 1 without a file; crossref already reached its CSV block. No test relied on the old 80/120 slicing. git merge-tree with #134 is clean and the merged tree passes 118 tests. Cosmetic only: SEC no-results prints 'Showing 0 of 0' twice.

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.

openfoia browse ignores network.tor unless --tor is passed

1 participant