{"record":{"id":"02e795c17cb0d695","repo":"abhigyanpatwari/GitNexus","slug":"model-auth-token-must-not-be-blank","errorCode":null,"errorMessage":"model auth token must not be blank","messagePattern":"model auth token must not be blank","errorType":"validation","errorClass":"SandboxError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/proposer_sandbox.py","lineNumber":299,"sourceCode":"        \"NO_COLOR\": \"1\",\n        \"GIT_TERMINAL_PROMPT\": \"0\",\n        \"GIT_CONFIG_NOSYSTEM\": \"1\",\n        \"NPM_CONFIG_UPDATE_NOTIFIER\": \"false\",\n        \"NPM_CONFIG_AUDIT\": \"false\",\n        \"NPM_CONFIG_FUND\": \"false\",\n        \"NPM_CONFIG_CACHE\": f\"{SANDBOX_TMP}/npm-cache\",\n        \"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC\": \"1\",\n        \"DISABLE_AUTOUPDATER\": \"1\",\n        \"CLAUDE_CODE_DISABLE_TELEMETRY\": \"1\",\n        \"CLAUDE_CODE_SUBPROCESS_ENV_SCRUB\": \"1\",\n        \"CLAUDE_CODE_DONT_INHERIT_ENV\": \"1\",\n        \"CLAUDE_CODE_SHELL_PREFIX\": SANDBOX_SHELL_PREFIX,\n        \"CLAUDE_CONFIG_DIR\": f\"{SANDBOX_HOME}/.claude\",\n    }\n    if auth_token is not None:\n        token = auth_token.strip()\n        if not token:\n            raise SandboxError(\"model auth token must not be blank\")\n        # Every benchmark/proposer invocation uses Claude's --bare mode,\n        # which intentionally ignores OAuth/keychain/AUTH_TOKEN credentials.\n        env[\"ANTHROPIC_API_KEY\"] = token\n    if base_url is not None:\n        env[\"ANTHROPIC_BASE_URL\"] = _validated_base_url(base_url)\n    return env\n\n\ndef build_claude_settings() -> str:\n    \"\"\"Inline settings: hooks/plugins are absent and every Bash stays sandboxed.\"\"\"\n\n    settings = {\n        \"sandbox\": {\n            \"enabled\": True,\n            \"failIfUnavailable\": True,\n            \"autoAllowBashIfSandboxed\": True,\n            \"allowUnsandboxedCommands\": False,\n            \"enableWeakerNestedSandbox\": True,","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/proposer_sandbox.py#L281-L317","documentation":"Raised by build_sandbox_environment when auth_token is not None but trims to empty. The sandbox injects the token as ANTHROPIC_API_KEY and treats an all-whitespace token as invalid because Claude's --bare mode would receive a blank key, producing confusing auth failures downstream.","triggerScenarios":"Calling build_sandbox_environment(auth_token='') or with a whitespace-only string ('   ', '\\t\\n'). Passing None skips the check (no key set); a non-None blank value trips it.","commonSituations":"Token read from an env var that was set but empty; token sourced from a secrets manager that returned whitespace; a config file had 'ANTHROPIC_API_KEY: ' with trailing space; copy-paste introduced only whitespace; a pytest fixture passed '' as a sentinel.","solutions":["Pass None when you have no token, rather than an empty string.","Source the token via the project's devkey/secrets flow and assert it is non-empty before calling.","Strip and validate upstream: token = token.strip() or None.","Fail fast at config load with a clear 'missing API key' message rather than at sandbox build."],"exampleFix":"// before\nenv = build_sandbox_environment(auth_token=os.environ.get('ANTHROPIC_API_KEY', ''))\n// after\nraw = os.environ.get('ANTHROPIC_API_KEY')\nenv = build_sandbox_environment(auth_token=raw.strip() or None if raw else None)","handlingStrategy":"validation","validationCode":"def normalized_token(raw: str | None) -> str | None:\n    if raw is None:\n        return None\n    stripped = raw.strip()\n    return stripped or None\n\nenv = build_sandbox_environment(auth_token=normalized_token(os.environ.get('ANTHROPIC_API_KEY')))","typeGuard":"def is_usable_token(value: object) -> bool:\n    return value is None or (isinstance(value, str) and value.strip() != '')","tryCatchPattern":"try:\n    env = build_sandbox_environment(auth_token=token)\nexcept SandboxError as exc:\n    if 'must not be blank' in str(exc):\n        env = build_sandbox_environment(auth_token=None)\n    raise","preventionTips":["Normalize tokens to None when blank before calling.","Source keys through the project's devkey/secrets flow.","Fail fast at config load if a required key is missing.","Distinguish 'unset' (None) from 'empty' ('') in config."],"tags":["config","auth","validation","sandbox"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}