{"record":{"id":"30d57c45760fcc8e","repo":"rtk-ai/rtk","slug":"consent-requires-interactive-terminal-cannot-ena","errorCode":null,"errorMessage":"consent requires interactive terminal — cannot enable telemetry in piped mode","messagePattern":"consent requires interactive terminal — cannot enable telemetry in piped mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/telemetry_cmd.rs","lineNumber":155,"sourceCode":"            env_override,\n            config.telemetry.enabled,\n            config.telemetry.consent_given,\n            hash.as_deref(),\n        )\n    );\n\n    println!();\n    println!(\"Data controller: RTK AI Labs, contact@rtk-ai.app\");\n    println!(\"Details: https://github.com/rtk-ai/rtk/blob/master/docs/TELEMETRY.md\");\n\n    Ok(())\n}\n\nfn run_enable() -> Result<()> {\n    use std::io::{self, BufRead, IsTerminal};\n\n    if !io::stdin().is_terminal() {\n        anyhow::bail!(\n            \"consent requires interactive terminal — cannot enable telemetry in piped mode\"\n        );\n    }\n\n    eprintln!(\"RTK collects anonymous usage metrics once per day to improve filters.\");\n    eprintln!();\n    eprintln!(\"  What:    command names (not arguments), token savings, OS, version\");\n    eprintln!(\"  Who:     RTK AI Labs, contact@rtk-ai.app\");\n    eprintln!(\"  Details: https://github.com/rtk-ai/rtk/blob/master/docs/TELEMETRY.md\");\n    eprintln!();\n    eprint!(\"Enable anonymous telemetry? [y/N] \");\n\n    let stdin = io::stdin();\n    let mut line = String::new();\n    stdin\n        .lock()\n        .read_line(&mut line)\n        .context(\"Failed to read user input\")?;","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/core/telemetry_cmd.rs#L137-L173","documentation":"Enabling RTK telemetry requires explicit, informed consent typed by a human. `run_enable` therefore refuses to run when stdin is not a TTY (`io::stdin().is_terminal()` is false), because a piped or scripted invocation cannot provide genuine interactive consent for anonymous usage-data collection.","triggerScenarios":"Running `rtk telemetry enable` (or whatever routes to run_enable) with stdin piped or redirected, e.g. `echo y | rtk telemetry enable`, inside CI scripts, non-interactive shells, docker exec without -t, or from another program spawning rtk without a TTY.","commonSituations":"Automating RTK setup in dotfiles or CI where a user tries to pre-answer the consent prompt; running inside containers or IDE terminals without a TTY; wrapping rtk commands in scripts that pipe stdin.","solutions":["Run the enable command in a real interactive terminal (no pipes/redirects on stdin).","Enable telemetry by setting the relevant config/env value directly (e.g. the telemetry opt-in key in rtk's config file or env var) instead of going through the interactive consent flow.","If automation is required, skip telemetry entirely or use a config-management step that writes the consent flag yourself, acknowledging the consent policy."],"exampleFix":"// before (script)\necho \"y\" | rtk telemetry enable\n\n// after\n# run interactively once:\nrtk telemetry enable\n# or set config directly:\nrtk config set telemetry.enabled true","handlingStrategy":"fallback","validationCode":"use std::io::IsTerminal;\nif !std::io::stdin().is_terminal() {\n    eprintln!(\"skipping `rtk telemetry enable`: requires interactive terminal\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match rtk_telemetry_enable().err() {\n    Some(e) if e.to_string().contains(\"interactive terminal\") => {\n        eprintln!(\"telemetry enable must be run interactively; skipping\");\n    }\n    _ => {}\n}","preventionTips":["Only invoke consent-requiring commands from interactive shells.","In install scripts, guard the call with a TTY check or skip telemetry setup entirely.","Prefer writing the telemetry config flag directly in automation rather than scripting the interactive prompt."],"tags":["telemetry","interactive-terminal","tty","cli"],"backgroundTag":"operation-not-supported","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}