{"record":{"id":"7fddb57c2c4f9726","repo":"nikivdev/code","slug":"follow-requires-specifying-server-name","errorCode":null,"errorMessage":"--follow requires specifying --server <name>","messagePattern":"--follow requires specifying --server <name>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/logs.rs","lineNumber":17,"sourceCode":"use std::{\n    io::{BufRead, BufReader},\n    thread,\n    time::Duration,\n};\n\nuse anyhow::{Context, Result, bail};\nuse reqwest::blocking::Client;\n\nuse crate::{\n    cli::LogsOpts,\n    servers::{LogLine, LogStream, ServerSnapshot},\n};\n\npub fn run(opts: LogsOpts) -> Result<()> {\n    if opts.follow && opts.server.is_none() {\n        bail!(\"--follow requires specifying --server <name>\");\n    }\n\n    let base_url = format!(\"http://{}:{}\", opts.host, opts.port);\n    let use_color = !opts.no_color;\n    let client = Client::builder()\n        .timeout(std::time::Duration::from_secs(5))\n        .build()\n        .context(\"failed to build HTTP client\")?;\n\n    if let Some(server) = opts.server.as_deref() {\n        if opts.follow {\n            stream_server_logs(server, opts.host, opts.port, use_color)?;\n        } else {\n            let logs = fetch_logs(&client, &base_url, server, opts.limit)?;\n            print_logs(&logs, use_color);\n        }\n        return Ok(());\n    }","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/logs.rs#L1-L35","documentation":"The logs command refuses to run in --follow mode without naming a server, because following requires a specific log stream to attach to; there is no defined behavior for following all servers. It is a usage-validation error thrown at the very start of `run` before any network activity.","triggerScenarios":"Invoking `flow logs --follow` (or setting LogsOpts.follow = true) while leaving LogsOpts.server as None.","commonSituations":"Typing the follow flag but forgetting the server name; scripting the logs command with a variable server name that ends up empty.","solutions":["Pass the server name: `flow logs --follow --server <name>`.","Run `flow servers` (or equivalent list command) to see available server names first.","If you just want a one-shot dump of all logs, drop `--follow`."],"exampleFix":"// before\nflow logs --follow\n// after\nflow logs --follow --server my-server","handlingStrategy":"validation","validationCode":"if opts.follow && opts.server.is_none() {\n    eprintln!(\"--follow requires --server <name>\");\n    std::process::exit(2);\n}","typeGuard":"fn follow_target_valid(opts: &LogsOpts) -> bool {\n    !opts.follow || opts.server.as_deref().map(|s| !s.is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match logs::run(opts) {\n    Err(e) if e.to_string().contains(\"--follow requires\") => {\n        eprintln!(\"Usage: flow logs --follow --server <name>\");\n        std::process::exit(2);\n    }\n    other => other?,\n}","preventionTips":["Always pair --follow with --server in scripts and aliases.","List available servers before following to confirm the name.","Wrap the logs command in a helper that injects the server name."],"tags":["cli","argument-validation","logs"],"backgroundTag":"missing-required-argument","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}