{"record":{"id":"041361ca9d501944","repo":"Hmbown/CodeWhale","slug":"read-codewhale-config-telemetry-then-explicitly-accept","errorCode":null,"errorMessage":"read `codewhale config telemetry`, then explicitly accept current notice version {}","messagePattern":"read `codewhale config telemetry`, then explicitly accept current notice version (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":2091,"sourceCode":"}\n\nfn arm_telemetry(cli: &Cli, command: Option<&Commands>) {\n    if telemetry_command_is_read_only(command) {\n        return;\n    }\n    arm_telemetry_with_setup(\n        cli.config.clone(),\n        telemetry_surface(command),\n        telemetry_session_source(command),\n        None,\n    );\n}\n\n/// Compatibility command to explicitly enable usage under the current policy.\n/// This optional choice never arms the current process.\npub fn accept_telemetry_notice(config_path: Option<PathBuf>, version: u32) -> Result<String> {\n    if version != codewhale_telemetry::NOTICE_VERSION {\n        anyhow::bail!(\n            \"read `codewhale config telemetry`, then explicitly accept current notice version {}\",\n            codewhale_config::TELEMETRY_NOTICE_VERSION\n        );\n    }\n    set_telemetry_preference(config_path, true)\n}\n\n/// Set the durable usage preference through the same transition as Settings.\n/// Enabling affects the next launch; disabling immediately erases queued usage.\npub fn set_telemetry_preference(config_path: Option<PathBuf>, enabled: bool) -> Result<String> {\n    let applied = crate::telemetry_notice::apply_persistent_preference(config_path, enabled);\n    let message = applied.message(codewhale_localization::Locale::En);\n    if applied.is_error() {\n        anyhow::bail!(\"{message}\");\n    }\n    Ok(message)\n}\n","sourceCodeStart":2073,"sourceCodeEnd":2109,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L2073-L2109","documentation":"`codewhale config telemetry-accept <version>` requires the caller to pass the version number matching the current telemetry notice version. Passing a stale or wrong version bails with instructions to read the current notice via `codewhale config telemetry` first. This is a deliberate read-before-accept gate so consent is always explicit and informed.","triggerScenarios":"Calling accept_telemetry_notice with a version argument that differs from codewhale_config::TELEMETRY_NOTICE_VERSION — e.g. hard-coded old version in a script, cached value from before a codewhale upgrade bumped the notice.","commonSituations":"Scripting the accept command with a literal version that has since been bumped; skipping the `codewhale config telemetry` read step; copy-pasted commands from old docs.","solutions":["Run `codewhale config telemetry` to read the current notice and its version","Re-run accept passing the current version shown in the notice","Remove any hard-coded version from scripts and derive it from the telemetry notice output"],"exampleFix":"// before\ncodewhale config telemetry-accept 1\n// after\nVERSION=$(codewhale config telemetry --print-version)\ncodewhale config telemetry-accept \"$VERSION\"","handlingStrategy":"validation","validationCode":"// read the current version first, never hard-code it\nlet notice = run(\"codewhale config telemetry\")?; // parse notice version from output\nassert_eq!(version_arg, notice.version);","typeGuard":null,"tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"explicitly accept current notice version\") => { let v = read_current_notice_version()?; retry_with_version(v); }, other => other? }","preventionTips":["Never hard-code the notice version in scripts; read it from `codewhale config telemetry`","Re-run the read step after every codewhale upgrade","Treat version mismatch as 'notice changed — re-read it', not a bug"],"tags":["cli","telemetry","consent"],"backgroundTag":"invalid-argument-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}