{"record":{"id":"e7eb3568f08f2ce0","repo":"astrid-runtime/astrid","slug":"daemon-log-target-env-must-be-exactly-file-or","errorCode":null,"errorMessage":"{DAEMON_LOG_TARGET_ENV} must be exactly 'file' or 'stderr', got {}","messagePattern":"(.+?) must be exactly 'file' or 'stderr', got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-daemon/src/lib.rs","lineNumber":105,"sourceCode":"            \"debug\".clone_into(&mut lc.level);\n        }\n        lc\n    } else {\n        let level = if verbose { \"debug\" } else { \"info\" };\n        astrid_telemetry::LogConfig::new(level).with_format(astrid_telemetry::LogFormat::Compact)\n    };\n\n    log_config.target = match target_override {\n        None => astrid_telemetry::LogTarget::File(astrid_home.log_dir()),\n        Some(target) if target == std::ffi::OsStr::new(\"file\") => {\n            astrid_telemetry::LogTarget::File(astrid_home.log_dir())\n        },\n        Some(target) if target == std::ffi::OsStr::new(\"stderr\") => {\n            log_config.ansi = false;\n            astrid_telemetry::LogTarget::Stderr\n        },\n        Some(target) => {\n            anyhow::bail!(\n                \"{DAEMON_LOG_TARGET_ENV} must be exactly 'file' or 'stderr', got {}\",\n                std::path::Path::new(target).display()\n            )\n        },\n    };\n    Ok(log_config)\n}\n\n#[cfg(unix)]\nfn init_logging(log_config: &astrid_telemetry::LogConfig) {\n    if let Err(e) = astrid_telemetry::setup_logging(log_config) {\n        eprintln!(\"Failed to initialize logging: {e}\");\n    }\n}\n\n#[cfg(unix)]\nfn defer_file_logging_until_kernel_admission(\n    astrid_home: &astrid_core::dirs::AstridHome,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-daemon/src/lib.rs#L87-L123","documentation":"The daemon reads its log-target configuration from an environment variable (DAEMON_LOG_TARGET_ENV) and only accepts the exact values 'file' or 'stderr'. daemon_log_config bails with this error when the variable is set to anything else, including misspellings, mixed case, whitespace, or other targets like 'stdout'.","triggerScenarios":"Setting DAEMON_LOG_TARGET_ENV to any value other than the exact strings \"file\" or \"stderr\" before starting the daemon.","commonSituations":"Typoed value (\"files\", \"File\", \"stderr \"); scripts exporting \"stdout\" expecting it to be supported; quoting mistakes leaving stray characters in the value; docs drift after the option was narrowed to two values.","solutions":["Set the env var to exactly `file` or `stderr` (lowercase, no whitespace).","Unset the variable entirely to get the default (file logging).","Print/echo the variable in the shell to catch hidden whitespace or quoting issues.","Fix wrapper scripts/systemd unit files that export an unsupported value."],"exampleFix":"// before\nexport ASTRID_DAEMON_LOG_TARGET=stdout\n// after\nexport ASTRID_DAEMON_LOG_TARGET=stderr   # or 'file', or unset for default","handlingStrategy":"validation","validationCode":"fn log_target_valid() -> bool {\n    match std::env::var(\"ASTRID_DAEMON_LOG_TARGET\") {\n        Err(_) => true,\n        Ok(v) => v == \"file\" || v == \"stderr\",\n    }\n}","typeGuard":null,"tryCatchPattern":"match daemon_log_config() {\n    Ok(cfg) => cfg,\n    Err(e) if e.to_string().contains(\"must be exactly 'file' or 'stderr'\") => {\n        eprintln!(\"{e:#}; falling back to default file logging\");\n        astrid_telemetry::LogConfig::default()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Only use the exact lowercase values 'file' or 'stderr'.","Prefer unsetting the variable to relying on a custom value for the default.","Trim/validate the value in wrapper scripts and systemd units before export.","Avoid 'stdout' — it is not a supported target."],"tags":["daemon","logging","environment","config"],"backgroundTag":"invalid-env-var-value","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}