{"record":{"id":"11380dac71d025f0","repo":"Panniantong/Agent-Reach","slug":"configure-value-exceeds-the-1-mib-safety-limit","errorCode":null,"errorMessage":"Configure value exceeds the 1 MiB safety limit","messagePattern":"Configure value exceeds the 1 MiB safety limit","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"agent_reach/cli.py","lineNumber":1347,"sourceCode":"            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):\n        interactive = False\n    if not interactive:\n        return \"\"","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/cli.py#L1329-L1365","documentation":"When reading a configure value from stdin, agent_reach/cli.py caps input at _MAX_CONFIGURE_VALUE_CHARS (1 MiB of characters). Reading one extra char detects overflow; if the value is longer, the CLI prints 'Configure value exceeds the 1 MiB safety limit' and exits 1 without storing anything. Real cookies and tokens are always far below this bound.","triggerScenarios":"`agent-reach configure <key> --stdin` where the piped input is over 1,048,576 characters — e.g. accidentally piping a cookie jar file, a browser profile directory dump, or a pasted document instead of the single cookie/token string.","commonSituations":"Users piping the wrong file into --stdin (an entire cookies.json export rather than the Cookie-Editor header string); scripts concatenating multiple values; binary files piped as text.","solutions":["Check what you are piping: wc -c < your-input — it must be under 1 MiB and contain just the one value","For cookies, paste only the Cookie-Editor 'Header String' or the token pair, not the whole export JSON","Trim accidental trailing content (multiple documents, log output) from the piped stream","If you genuinely need a huge value, store it in the environment (Config.get also reads uppercase env vars) instead of the config file"],"exampleFix":"# before: piping an entire browser cookie export (often > 1 MiB)\ncat ~/Downloads/cookies_export.json | agent-reach configure twitter-cookies --stdin\n\n# after: extract just the header string first\npython -c \"import json;d=json.load(open('cookies_export.json'));print('; '.join(f'{c[\\\"name\\\"]}={c[\\\"value\\\"]}' for c in d))\" | agent-reach configure twitter-cookies --stdin","handlingStrategy":"validation","validationCode":"MAX = 1024 * 1024  # mirrors _MAX_CONFIGURE_VALUE_CHARS\n\ndef fits_configure_limit(payload: str) -> bool:\n    return len(payload) <= MAX\n\nassert fits_configure_limit(cookie_header), \"value exceeds the 1 MiB configure limit\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pipe only the exact token/cookie string, never whole export JSON files or documents","Sanity-check inputs with `wc -c` before feeding --stdin","A real secret never approaches 1 MiB; an oversize input almost always means you selected the wrong data"],"tags":["cli","configure","stdin","safety-limit","exit-code-1"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}