Machine-readable output is corrupted: HTTP warning goes to stdout, so --format json is invalid JSON

Open Beginner friendly
#81 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Start with the two warning calls in wpa/config.py at lines 97 and 258, then reproduce against an http:// private/LAN site using the commands in the issue. Move the diagnostic output away from stdout and add a regression test for machine-readable output. Done means --format json remains parseable and --field, --ids, --count, and CSV/TSV output contain only data on stdout.

Written by the indexing model from the issue text.

Description

bug

Summary

On any site configured over http:// with a private/LAN address, the warning

Warning: Using HTTP on a private/LAN address. Credentials are not encrypted in transit.

is printed to stdout, not stderr. It is therefore prepended to the payload of every
machine-readable output mode, and --format json emits invalid JSON.

Reproduction

Against a LAN site (here CT118, http://192.168.52.18), redirecting stderr away entirely:

$ wpa theme list --site ct118 --format json 2>/dev/null | python3 -c "import sys,json; json.load(sys.stdin)"
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

$ wpa theme list --site ct118 --format json 2>/dev/null | head -2
Warning: Using HTTP on a private/LAN address. Credentials are not encrypted in transit.
[

--field is corrupted the same way — the value is no longer the only thing on stdout:

$ wpa theme list --site ct118 --status active --field stylesheet 2>/dev/null
Warning: Using HTTP on a private/LAN address. Credentials are not encrypted in transit.
twentytwentyfive

2>/dev/null is in each command deliberately: it proves the text is on stdout rather than stderr.

Cause

Two bare print() calls with no file=sys.stderr:

  • wpa/config.py:97
  • wpa/config.py:258

Impact

--format json, --field, --ids, --count and --format csv/tsv exist to be consumed by
other programs. On LAN/HTTP sites — an environment wpa explicitly supports, and the usual shape
of a staging box — none of them can be consumed without filtering the first line, and any caller
that pipes straight into a JSON parser fails.

The warning itself is correct and worth keeping. It is diagnostic output, so it belongs on stderr,
where it stays visible to an operator and out of the data.

Suggested fix

Add file=sys.stderr to both calls. A regression test asserting that
--format json stdout parses as JSON against an http:// private-address site would keep it
from coming back — the bug is invisible over HTTPS, which is why it survived to v0.11.0.

Found by

The v0.11.0 release-gate smoke test (examples/bootstrap-site.sh) run against CT118
(wp-stage-18, WordPress on Twenty Twenty-Five) on 2026-08-12.

— SAM

Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cadentdev/wpa

All issues in cadentdev/wpa

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.