{"record":{"id":"a31103179602ace7","repo":"a-b-street/abstreet","slug":"unknown-mode","errorCode":null,"errorMessage":"Unknown mode {}","messagePattern":"Unknown mode (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"importer/src/soundcast/popdat.rs","lineNumber":265,"sourceCode":"        \"8.0\" => TripPurpose::Recreation,\n        \"9.0\" => TripPurpose::Medical,\n        \"10.0\" => TripPurpose::ParkAndRideTransfer,\n        _ => panic!(\"Unknown dpurp {}\", code),\n    }\n}\n\n// From https://github.com/psrc/soundcast/wiki/Outputs#trip-file-_triptsv, mode\nfn get_mode(code: &str) -> TripMode {\n    match code {\n        \"1.0\" => TripMode::Walk,\n        \"2.0\" => TripMode::Bike,\n        \"3.0\" | \"4.0\" | \"5.0\" => TripMode::Drive,\n        // TODO Park-and-ride and school bus as walk-to-transit is a little weird.\n        \"6.0\" | \"7.0\" | \"8.0\" => TripMode::Transit,\n        // TODO Invalid code, what's this one mean? I only see a few examples, so just default to\n        // walking.\n        \"0.0\" => TripMode::Walk,\n        _ => panic!(\"Unknown mode {}\", code),\n    }\n}\n\n// See https://github.com/psrc/soundcast/wiki/Outputs#trip-file-_triptsv\n//\n// A/B Street flattens a person's trips into a simple list, but the Soundcast model is more\n// detailed:\n//\n// A person takes 1+ tours a day. Each tour starts and ends at the same place (usually home) and\n// has some primary destination. A tour has two legs (to the destination, then returning from it),\n// each split into individual trips.\n//\n// An example: someone takes the bus to work, but stops for a coffee and walks the final bit to\n// work. Then later they bus home. This would be encoded like so:\n//\n// - Tour 1 (purpose work), leg = to destination, trip 1 (purpose eat, using transit)\n// - Tour 1 (purpose work), leg = to destination, trip 2 (purpose work, walking)\n// - Tour 1 (purpose work), leg = return from destination, trip 1 (purpose home, using transit)","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/importer/src/soundcast/popdat.rs#L247-L283","documentation":"get_mode maps the Soundcast trip file's mode column codes to a TripMode (Drive for 3.0-5.0, Transit for 6.0-8.0, Walk for 0.0, etc.). Any unrecognized mode string panics with \"Unknown mode {code}\" during scenario import. Strictness is deliberate so unknown modal codes aren't silently miscategorized.","triggerScenarios":"Calling import_trips on a _trip.tsv whose mode column contains a value outside the mapped set (e.g. \"9.0\", \"NA\", blank, or codes from a different model version).","commonSituations":"Newer PSRC Soundcast releases adding mode categories; malformed TSV rows; using trip files from a different regional model with different coding; hand-edited input data.","solutions":["Look up the offending mode code in the psrc/soundcast wiki (_trip.tsv docs) and either fix the data or add a mapping arm.","Default unknown codes to TripMode::Walk (as already done for the invalid \"0.0\" code) instead of panicking, if approximate mapping is acceptable.","Pre-validate the trip file's mode column against the known set before running the import.","Regenerate inputs with the matching Soundcast model version."],"exampleFix":"// before\n_ => panic!(\"Unknown mode {}\", code),\n// after\nother => {\n    warn!(\"Unknown mode {}, treating as walk\", other);\n    TripMode::Walk\n}","handlingStrategy":"validation","validationCode":"const KNOWN_MODES: [&str; 9] = [\"0.0\",\"1.0\",\"2.0\",\"3.0\",\"4.0\",\"5.0\",\"6.0\",\"7.0\",\"8.0\"];\nlet bad: Vec<_> = rows.iter().filter(|r| !KNOWN_MODES.contains(&r.mode.as_str())).collect();\nassert!(bad.is_empty(), \"unknown mode values: {:?}\", bad);","typeGuard":"fn is_known_mode(code: &str) -> bool {\n    matches!(code, \"0.0\"|\"1.0\"|\"2.0\"|\"3.0\"|\"4.0\"|\"5.0\"|\"6.0\"|\"7.0\"|\"8.0\")\n}","tryCatchPattern":"// Panics uncatchably; coerce before import:\nlet mode = if is_known_mode(raw) { raw } else { \"0.0\".to_string() };","preventionTips":["Cross-check mode codes against the psrc/soundcast wiki for your model version.","Pre-scan the mode column and report distinct unknown values in bulk.","Keep trip inputs from the same Soundcast run as other population files."],"tags":["panic","enum","data-import","soundcast"],"backgroundTag":"invalid-enum-value","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}