{"record":{"id":"66f9ddf0d62687f5","repo":"Panniantong/Agent-Reach","slug":"could-not-read-configure-value-from-stdin","errorCode":null,"errorMessage":"Could not read configure value from stdin","messagePattern":"Could not read configure value from stdin","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"agent_reach/cli.py","lineNumber":1344,"sourceCode":"        import subprocess\n        result = subprocess.run([\"systemd-detect-virt\"], capture_output=True, encoding=\"utf-8\", errors=\"replace\", timeout=3)\n        if result.returncode == 0 and result.stdout.strip() != \"none\":\n            indicators += 1\n    except Exception:\n        pass\n\n    return \"server\" if indicators >= 2 else \"local\"\n\n\ndef _read_configure_value(args) -> str:\n    \"\"\"Read one configure value without echoing secrets by default.\"\"\"\n    values = getattr(args, \"value\", None) or []\n    if getattr(args, \"read_stdin\", False):\n        try:\n            value = sys.stdin.read(_MAX_CONFIGURE_VALUE_CHARS + 1)\n        except OSError:\n            print(\"Could not read configure value from stdin\", file=sys.stderr)\n            raise SystemExit(1) from None\n        if len(value) > _MAX_CONFIGURE_VALUE_CHARS:\n            print(\"Configure value exceeds the 1 MiB safety limit\", file=sys.stderr)\n            raise SystemExit(1)\n        return value.rstrip(\"\\r\\n\")\n\n    if values:\n        if getattr(args, \"key\", None) in _SENSITIVE_CONFIG_KEYS:\n            print(\n                \"Warning: positional secrets are deprecated because shell history \"\n                \"and process listings may expose them; omit the value for a hidden \"\n                \"prompt or use --stdin.\",\n                file=sys.stderr,\n            )\n        return \" \".join(values)\n\n    try:\n        interactive = bool(sys.stdin.isatty())\n    except (AttributeError, OSError):","sourceCodeStart":1326,"sourceCodeEnd":1362,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/cli.py#L1326-L1362","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (producer failure closes the pipe)\ncat ./missing-cookie-file.txt | agent-reach configure twitter-cookies --stdin\n\n# after (explicit file that must exist, fail fast on the producer)\ntest -f ./cookie.txt && agent-reach configure twitter-cookies --stdin < ./cookie.txt","handlingStrategy":"try-catch","validationCode":"# ensure stdin is a usable pipe/file before invoking the CLI\nimport os, subprocess, sys\n\nif os.isatty(0) or sys.stdin is None:\n    sys.exit(\"refusing --stdin without piped input\")","typeGuard":null,"tryCatchPattern":"# in shell pipelines, guard the producer instead of catching in Python:\n#   producer | agent-reach configure key --stdin || { echo \"pipeline failed\" >&2; exit 1; }\n# Python callers of the CLI:\nimport subprocess\nr = subprocess.run([\"agent-reach\", \"configure\", key, \"--stdin\"], input=value, text=True)\nif r.returncode == 1 and \"stdin\" in r.stderr:\n    rerun_with_input_file(value)","preventionTips":["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"],"tags":["cli","configure","stdin","io-error","exit-code-1"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}