Panniantong/Agent-Reach · error · SystemExit
Could not read configure value from stdin
Error message
Could not read configure value from stdin
What it means
In `agent-reach configure <key> --stdin`, the CLI reads the value from sys.stdin (bounded to _MAX_CONFIGURE_VALUE_CHARS + 1 chars). If the read itself raises OSError, it prints 'Could not read configure value from stdin' to stderr and exits 1. This is an I/O failure on the input stream, not a problem with the value.
Source
Thrown at agent_reach/cli.py:1344
import subprocess
result = subprocess.run(["systemd-detect-virt"], capture_output=True, encoding="utf-8", errors="replace", timeout=3)
if result.returncode == 0 and result.stdout.strip() != "none":
indicators += 1
except Exception:
pass
return "server" if indicators >= 2 else "local"
def _read_configure_value(args) -> str:
"""Read one configure value without echoing secrets by default."""
values = getattr(args, "value", None) or []
if getattr(args, "read_stdin", False):
try:
value = sys.stdin.read(_MAX_CONFIGURE_VALUE_CHARS + 1)
except OSError:
print("Could not read configure value from stdin", file=sys.stderr)
raise SystemExit(1) from None
if len(value) > _MAX_CONFIGURE_VALUE_CHARS:
print("Configure value exceeds the 1 MiB safety limit", file=sys.stderr)
raise SystemExit(1)
return value.rstrip("\r\n")
if values:
if getattr(args, "key", None) in _SENSITIVE_CONFIG_KEYS:
print(
"Warning: positional secrets are deprecated because shell history "
"and process listings may expose them; omit the value for a hidden "
"prompt or use --stdin.",
file=sys.stderr,
)
return " ".join(values)
try:
interactive = bool(sys.stdin.isatty())
except (AttributeError, OSError):View on GitHub (pinned to 93ae1d18c3)
Solutions
- Verify the producer side of the pipe actually succeeds before piping into agent-reach
- Use a heredoc or a file redirect instead: agent-reach configure key --stdin < value.txt
- If running under systemd/cron, set StandardInput=file:/path or use the hidden-prompt mode (omit --stdin) interactively
- Check the exit status of the whole pipeline; the producer's error is usually the root cause
Example fix
# before (producer failure closes the pipe) cat ./missing-cookie-file.txt | agent-reach configure twitter-cookies --stdin # after (explicit file that must exist, fail fast on the producer) test -f ./cookie.txt && agent-reach configure twitter-cookies --stdin < ./cookie.txt
Defensive patterns
Strategy: try-catch
Validate before calling
# ensure stdin is a usable pipe/file before invoking the CLI
import os, subprocess, sys
if os.isatty(0) or sys.stdin is None:
sys.exit("refusing --stdin without piped input") Try / catch
# in shell pipelines, guard the producer instead of catching in Python:
# producer | agent-reach configure key --stdin || { echo "pipeline failed" >&2; exit 1; }
# Python callers of the CLI:
import subprocess
r = subprocess.run(["agent-reach", "configure", key, "--stdin"], input=value, text=True)
if r.returncode == 1 and "stdin" in r.stderr:
rerun_with_input_file(value) Prevention
- Always `set -o pipefail` in bash pipelines so a dead producer surfaces as a failure
- Prefer file redirection (--stdin < file) over long pipes; it fails fast and is inspectable
- In systemd units, set StandardInput explicitly rather than leaving it closed
When it happens
Trigger: Running `agent-reach configure twitter-cookies --stdin` where stdin is a closed pipe (`agent-reach configure x --stdin <&-`), a broken pipe from a producer that died, or a non-blocking/invalid fd in exotic process managers.
Common situations: Piping from a command that fails early (`cat missing.txt | agent-reach configure key --stdin` where the shell still runs the consumer); cron/systemd units with stdin closed; process substitution edge cases in CI shells.
Related errors
- Configure value exceeds the 1 MiB safety limit
- Configure input cancelled
- No cookies found. Make sure you're logged into the platforms
- Missing value for {args.key}
- [X] Could not find auth_token and ct0 in your input.
AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14).
Data as JSON: /api/errors/66f9ddf0d62687f5.
Report an issue: GitHub.