Panniantong/Agent-Reach · error · SystemExit

Configure value exceeds the 1 MiB safety limit

Error message

Configure value exceeds the 1 MiB safety limit

What it means

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.

Source

Thrown at agent_reach/cli.py:1347

            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):
        interactive = False
    if not interactive:
        return ""

View on GitHub (pinned to 93ae1d18c3)

Solutions

  1. Check what you are piping: wc -c < your-input — it must be under 1 MiB and contain just the one value
  2. For cookies, paste only the Cookie-Editor 'Header String' or the token pair, not the whole export JSON
  3. Trim accidental trailing content (multiple documents, log output) from the piped stream
  4. If you genuinely need a huge value, store it in the environment (Config.get also reads uppercase env vars) instead of the config file

Example fix

# before: piping an entire browser cookie export (often > 1 MiB)
cat ~/Downloads/cookies_export.json | agent-reach configure twitter-cookies --stdin

# after: extract just the header string first
python -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
Defensive patterns

Strategy: validation

Validate before calling

MAX = 1024 * 1024  # mirrors _MAX_CONFIGURE_VALUE_CHARS

def fits_configure_limit(payload: str) -> bool:
    return len(payload) <= MAX

assert fits_configure_limit(cookie_header), "value exceeds the 1 MiB configure limit"

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14). Data as JSON: /api/errors/11380dac71d025f0. Report an issue: GitHub.