{"record":{"id":"186e4b1d02639809","repo":"nushell/nushell","slug":"context-err","errorCode":null,"errorMessage":"{context}: {err}","messagePattern":"\\{context\\}: \\{err\\}","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/nu-command/src/platform/input/list.rs","lineNumber":89,"sourceCode":"// - STREAM_PREFETCH_MARGIN: how far from the end we begin prefetching.\n// - STREAM_CHANNEL_CAPACITY: rows the background reader can collect before the UI drains them.\n// - STREAM_POLL_INTERVAL: render cadence while a stream is still loading.\n// - STREAM_FOOTER_UPDATE_INTERVAL: visible footer animation/count cadence while rows stream in.\nconst INITIAL_STREAM_COLLECT_TIMEOUT: Duration = Duration::from_millis(250);\nconst INITIAL_STREAM_MAX_ITEMS: usize = 100_000;\nconst STREAM_LOAD_BATCH: usize = 512;\nconst STREAM_PREFETCH_MARGIN: usize = 2;\nconst STREAM_CHANNEL_CAPACITY: usize = 8192;\nconst STREAM_SPINNER_FRAMES: &[&str] = &[\"-\", \"\\\\\", \"|\", \"/\"];\nconst STREAM_DRAIN_TIME_BUDGET: Duration = Duration::from_millis(16);\nconst STREAM_POLL_INTERVAL: Duration = Duration::from_millis(16);\nconst STREAM_FOOTER_UPDATE_INTERVAL: Duration = Duration::from_millis(125);\nconst IDLE_POLL_INTERVAL: Duration = Duration::from_millis(100);\nconst FUZZY_FILTER_INTERRUPT_CHECK_INTERVAL: usize = 1024;\nconst FUZZY_FILTER_MIN_INTERRUPT_TIME: Duration = Duration::from_millis(16);\n\nfn io_context(context: &'static str) -> impl FnOnce(io::Error) -> io::Error {\n    move |err| io::Error::new(err.kind(), format!(\"{context}: {err}\"))\n}\n\nfn terminal_char_width(c: char, current_column: usize) -> usize {\n    match c {\n        '\\t' => {\n            let next_tab_stop = ((current_column / 8) + 1) * 8;\n            next_tab_stop - current_column\n        }\n        c if c.is_control() => 0,\n        c => UnicodeWidthChar::width(c).unwrap_or(0),\n    }\n}\n\nfn terminal_text_width_from(text: &str, start_column: usize) -> usize {\n    let mut current_column = start_column;\n    let mut chars = text.chars().peekable();\n\n    while let Some(c) = chars.next() {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/nushell/nushell/blob/38769348f424c9006b4ee28a97532ee6b0571beb/crates/nu-command/src/platform/input/list.rs#L71-L107","documentation":"`input list` runs a crossterm-based interactive selector that must enable raw mode, hide the cursor, query terminal size, render frames, and poll/read terminal events. `io_context` decorates any io::Error from those steps with a static label ('enable raw mode', 'hide terminal cursor', 'poll terminal event', ...) while preserving the original ErrorKind, so failures surface as '<step>: <cause>'.","triggerScenarios":"Running `input list ...` when stdin/stdout is not a TTY (piped script, CI job, redirected output) so raw mode cannot be enabled; reading terminal size where none is reported; event read after the terminal closed.","commonSituations":"Scripts using `input list` executed non-interactively (cron, CI, subprocess pipes); running nu in environments without a real or emulated terminal; terminal multiplexers dropping the tty.","solutions":["Run the script in a real terminal or provide a PTY (`docker -it`, expect, ssh -t).","Branch on interactivity: `if (term size).columns > 0 { input list ... } else { 'default' }`.","For scheduled runs, replace `input list` with flags, arguments, or env-var defaults."],"exampleFix":"# before\nlet choice = (input list --prompt pick: [a b])  # in CI: 'enable raw mode: ...'\n\n# after\nlet choice = if ((term size).columns > 0) { input list --prompt pick: [a b] } else { 'a' }","handlingStrategy":"validation","validationCode":"# Nushell: only prompt when a terminal is attached\nlet interactive = (try { term size; true } catch { false })\nlet choice = if $interactive { input list [a b] } else { 'default' }","typeGuard":null,"tryCatchPattern":"try { input list [a b] } catch { |err| print ($err.msg); 'default' }","preventionTips":["Never call `input list` unconditionally in scripts that may run non-interactively.","Provide non-interactive overrides via flags or environment variables.","Test prompts in CI with a PTY harness when interactive behavior must be covered."],"tags":["nushell","terminal","interactive","io","input-list"],"backgroundTag":null,"analyzedSha":"38769348f424c9006b4ee28a97532ee6b0571beb","analyzedAt":"2026-08-16T10:05:45.512Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}