{"record":{"id":"d0b52e44a3ca5b30","repo":"a-b-street/abstreet","slug":"some-trip-has-negative-departure-time","errorCode":null,"errorMessage":"Some trip has negative departure time {:?}","messagePattern":"Some trip has negative departure time (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"synthpop/src/external.rs","lineNumber":88,"sourceCode":"            }\n        };\n\n        let mut results = Vec::new();\n        for person in input {\n            let mut spec = PersonSpec {\n                orig_id: None,\n                trips: Vec::new(),\n            };\n            for trip in person.trips {\n                if trip.departure < Time::START_OF_DAY {\n                    if skip_problems {\n                        warn!(\n                            \"Skipping trip with negative departure time {:?}\",\n                            trip.departure\n                        );\n                        continue;\n                    } else {\n                        bail!(\"Some trip has negative departure time {:?}\", trip.departure);\n                    }\n                }\n\n                spec.trips.push(IndividTrip::new(\n                    trip.departure,\n                    trip.purpose,\n                    match lookup_pt(trip.origin, true, trip.mode) {\n                        Ok(endpt) => endpt,\n                        Err(err) => {\n                            if skip_problems {\n                                warn!(\"Skipping person: {}\", err);\n                                continue;\n                            } else {\n                                return Err(err);\n                            }\n                        }\n                    },\n                    match lookup_pt(trip.destination, false, trip.mode) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/synthpop/src/external.rs#L70-L106","documentation":"During external population import, trips are validated and any trip whose departure time is negative makes the whole import fail. A code path exists to warn and skip such trips, but when that path is not taken the import bails on the first negative departure.","triggerScenarios":"Importing an external population/scenario file where one or more trips have departure times before the simulation's time origin (negative Time), typically due to misaligned day offsets or malformed timestamps.","commonSituations":"Feed data with timestamps from a different day boundary or timezone, precomputed populations exported with unsigned-to-signed conversion bugs, joining datasets without normalizing departure times.","solutions":["Fix or regenerate the input population so all trip departures are non-negative","Normalize timestamps to the simulation's time origin before import","Pre-filter the dataset to drop negative-departure trips","If skipping is acceptable, adjust the import code to always use the warn+continue branch"],"exampleFix":"// before\nlet departure = raw.ts; // may be negative\n// after\nlet departure = raw.ts.max(Time::START_OF_DAY);","handlingStrategy":"validation","validationCode":"if trips.iter().any(|t| t.depart < Time::START_OF_DAY) {\n    return Err(anyhow!(\"input has negative departure times\"));\n}","typeGuard":null,"tryCatchPattern":"match import(raw) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"negative departure\") => {\n        eprintln!(\"normalizing timestamps and retrying\");\n        import(normalize_departures(raw))?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Normalize all timestamps to the simulation epoch before import","Clamp negative departures to START_OF_DAY with a warning","Add a pre-import schema check on departure fields"],"tags":["import","synthpop","validation"],"backgroundTag":"value-out-of-range","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"}