{"record":{"id":"9f868966516ac30e","repo":"nikivdev/code","slug":"maple-api-token-is-not-configured","errorCode":null,"errorMessage":"MAPLE_API_TOKEN is not configured","messagePattern":"MAPLE_API_TOKEN is not configured","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/codex_telemetry.rs","lineNumber":547,"sourceCode":"        endpoint: config.endpoint,\n        token_source: config.token_source,\n        tools_list_ok: true,\n        tools_count: tools.len(),\n        read_probe_ok: read_probe\n            .as_ref()\n            .ok()\n            .and_then(maple_tool_result_error)\n            .is_none(),\n        read_probe_error: match read_probe {\n            Ok(value) => maple_tool_result_error(&value),\n            Err(error) => Some(error.to_string()),\n        },\n    })\n}\n\npub fn inspect_trace(trace_id: &str, flush_first: bool) -> Result<CodexTraceInspectResult> {\n    let Some(config) = parse_maple_read_config_from_env()? else {\n        anyhow::bail!(\"MAPLE_API_TOKEN is not configured\");\n    };\n    let flushed = if flush_first {\n        let _ = flush(64);\n        true\n    } else {\n        false\n    };\n    let result = maple_call_tool(\n        &config,\n        \"inspect_trace\",\n        serde_json::json!({\n            \"trace_id\": trace_id,\n        }),\n    );\n    let (result, read_error) = match result {\n        Ok(result) => (Some(result), None),\n        Err(error) => (None, Some(error.to_string())),\n    };","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/codex_telemetry.rs#L529-L565","documentation":"This error is raised by the public `inspect_trace` function when `parse_maple_read_config_from_env` returns no config, which happens when the MAPLE_API_TOKEN environment variable is unset or empty. The library refuses to proceed because it cannot authenticate to the Maple MCP endpoint to read trace data. It is a configuration gate, not a runtime failure.","triggerScenarios":"Calling `inspect_trace` (directly or via `inspect_current_session_trace`) in an environment where MAPLE_API_TOKEN is not set, e.g. a fresh shell, a CI job without secrets, or running the binary via a service manager that does not inherit your shell env.","commonSituations":"Forgetting to `export MAPLE_API_TOKEN=...` before running the tool, secrets not injected in CI (missing env mapping in the workflow), dotenv file not loaded, or running under sudo/systemd which strips the environment.","solutions":["Export the token: `export MAPLE_API_TOKEN=<your-token>` in the shell running the tool.","In CI, add MAPLE_API_TOKEN to the job's environment/secrets mapping.","If using a .env file, ensure it is loaded before the process starts.","Verify with `echo ${MAPLE_API_TOKEN:+set}` that the variable is visible to the process."],"exampleFix":"// before: fails because token is unset\ninspect_trace(\"abc123\", true)?;\n// after\n// $ export MAPLE_API_TOKEN=sk-...\ninspect_trace(\"abc123\", true)?;","handlingStrategy":"validation","validationCode":"fn ensure_maple_read_config() -> Result<(), String> {\n    match std::env::var(\"MAPLE_API_TOKEN\") {\n        Ok(t) if !t.trim().is_empty() => Ok(()),\n        _ => Err(\"MAPLE_API_TOKEN must be exported and non-empty before calling inspect_trace\".into()),\n    }\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = ensure_maple_read_config() {\n    eprintln!(\"{e}; run: export MAPLE_API_TOKEN=<token>\");\n    std::process::exit(2);\n}\nlet result = inspect_trace(trace_id, true)?;","preventionTips":["Export MAPLE_API_TOKEN in your shell profile or use a direnv/.env loader","In CI, map the token from the secrets store into the job environment","Never run the tool under sudo/systemd without passing the environment through (systemd: EnvironmentFile=)","Add a startup assertion that required env vars are present"],"tags":["config","env-var","authentication","mcp"],"backgroundTag":"missing-env-var","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}