{"record":{"id":"c9424435f59812bb","repo":"a-b-street/abstreet","slug":"bad-alerts-must-be-print-block-silence","errorCode":null,"errorMessage":"Bad --alerts={}. Must be print|block|silence","messagePattern":"Bad --alerts=(.+?)\\. Must be print\\|block\\|silence","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sim/src/sim/mod.rs","lineNumber":182,"sourceCode":"    Print,\n    /// Print the alert to STDOUT and don't proceed until the UI calls clear_alerts()\n    Block,\n    /// Don't do anything\n    Silence,\n}\n\nimpl Default for AlertHandler {\n    fn default() -> AlertHandler {\n        AlertHandler::Print\n    }\n}\n\nfn parse_alert_handler(x: &str) -> Result<AlertHandler> {\n    match x {\n        \"print\" => Ok(AlertHandler::Print),\n        \"block\" => Ok(AlertHandler::Block),\n        \"silence\" => Ok(AlertHandler::Silence),\n        _ => bail!(\"Bad --alerts={}. Must be print|block|silence\", x),\n    }\n}\n\n// Setup\nimpl Sim {\n    pub fn new(map: &Map, mut opts: SimOptions) -> Sim {\n        let mut timer = Timer::new(\"create blank sim\");\n        let mut scheduler = Scheduler::new();\n\n        // Always disable parking for two maps. See\n        // https://github.com/a-b-street/abstreet/issues/688 for discussion of how to set this\n        // properly.\n        if map.get_name() == &MapName::seattle(\"arboretum\")\n            || map.get_name().city == CityName::new(\"ir\", \"tehran\")\n            || map.get_name() == &MapName::new(\"gb\", \"poundbury\", \"center\")\n            || map.get_name() == &MapName::new(\"us\", \"phoenix\", \"tempe\")\n            || map.get_name() == &MapName::new(\"br\", \"sao_paulo\", \"sao_miguel_paulista\")\n        {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/sim/src/sim/mod.rs#L164-L200","documentation":"This error comes from the CLI argument parser for the --alerts flag in the simulator. The flag controls how in-game alerts are handled, and it accepts exactly three values: print, block, or silence. Any other string fails with this message, echoing the bad value and the valid choices.","triggerScenarios":"Calling the sim binary (or SimOptions parsing path) with --alerts set to anything other than print, block, or silence, including typos like 'blockq', capitalized 'Print', or an empty string.","commonSituations":"Typos in shell scripts or run configs, copy-pasting flag values from docs of other tools, environment-specific wrappers that interpolate an unexpected value into --alerts.","solutions":["Change the --alerts value to exactly one of print, block, or silence","Check for case sensitivity and stray whitespace in the flag value","If you need a new handler, add a match arm in parse_alert_handler in sim/src/sim/mod.rs"],"exampleFix":"// before\n--alerts=Blocks\n// after\n--alerts=block","handlingStrategy":"validation","validationCode":"const VALID_ALERTS: [&str; 3] = [\"print\", \"block\", \"silence\"];\nif !VALID_ALERTS.contains(&alerts.as_str()) {\n    eprintln!(\"--alerts must be print|block|silence, got: {}\", alerts);\n    std::process::exit(2);\n}","typeGuard":"fn is_valid_alert_handler(x: &str) -> bool {\n    matches!(x, \"print\" | \"block\" | \"silence\")\n}","tryCatchPattern":null,"preventionTips":["Wrap simulator invocations in a script that validates flags before launch","Use an enum-typed CLI parser (e.g. clap with ValueEnum) instead of raw string matching","Add a shell-completion or help text listing the three valid values"],"tags":["cli","parsing","config"],"backgroundTag":"invalid-cli-argument","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}