{"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":81,"sourceCode":"    if salt_path.exists() {\n        let hash = super::telemetry::generate_device_hash();\n        println!(\"  device hash:   {}...{}\", &hash[..8], &hash[56..]);\n    } else {\n        println!(\"  device hash:   (no salt file)\");\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":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/rtk-ai/rtk/blob/d977e1c31621fe8704e6500ceeb9c7a0de2b6836/src/core/telemetry_cmd.rs#L63-L99","documentation":"`rtk telemetry enable` must collect explicit y/N consent, so run_enable requires stdin to be a TTY (io::stdin().is_terminal()) and bails otherwise. The guard is deliberate: consent piped from a script, CI job, or agent is not consent the user actually gave, so RTK refuses to enable telemetry non-interactively.","triggerScenarios":"`echo y | rtk telemetry enable`; `rtk telemetry enable < /dev/null`; running the command inside an agent hook/wrapper where stdin is a pipe, not a terminal; nohup/cron/SSH-without-tty contexts. Anything where is_terminal() returns false.","commonSituations":"Automation or install scripts trying to pre-accept telemetry; an AI agent running the command on the user's behalf via a bash tool (stdin is a pipe there by definition); CI smoke tests touching telemetry.","solutions":["Run `rtk telemetry enable` yourself in an interactive terminal and answer the [y/N] prompt","In automation, treat this failure as the intended consent guard — leave telemetry disabled rather than scripting around it","Inspect state non-interactively instead: `rtk telemetry status` reads/prints without needing a TTY"],"exampleFix":"# before (agent/CI shell: stdin is a pipe)\necho y | rtk telemetry enable\n# consent requires interactive terminal — cannot enable telemetry in piped mode\n\n# after: user runs it directly in their terminal\nrtk telemetry enable   # answers the [y/N] prompt interactively","handlingStrategy":"validation","validationCode":"bash:\n# only attempt interactive enable when stdin is a real TTY\nif [ -t 0 ]; then\n  rtk telemetry enable\nelse\n  echo \"rtk telemetry enable needs an interactive terminal; run it yourself\" >&2\nfi","typeGuard":null,"tryCatchPattern":"rust:\nuse std::io::IsTerminal;\nif !std::io::stdin().is_terminal() {\n    eprintln!(\"telemetry consent must be given interactively; skipping\");\n    return Ok(()); // treat as skip, not failure, in automation\n}\ntelemetry_cmd::run_enable()?;","preventionTips":["Run `rtk telemetry enable` personally in a terminal; never script the y/N","Agents/CI: check `rtk telemetry status` instead — it is non-interactive","Treat the piped-mode failure as the consent guard working, not a bug to bypass"],"tags":["telemetry","tty","interactive","consent","usage"],"backgroundTag":null,"analyzedSha":"d977e1c31621fe8704e6500ceeb9c7a0de2b6836","analyzedAt":"2026-08-16T05:40:46.291Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}