{"record":{"id":"30d6dac67c5430c4","repo":"a-b-street/abstreet","slug":"it-s-now-so-you-can-t-start-a-trip-at","errorCode":null,"errorMessage":"It's {} now, so you can't start a trip at {}","messagePattern":"It's (.+?) now, so you can't start a trip at (.+?)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"headless/src/main.rs","lineNumber":197,"sourceCode":"            *sim = Sim::new(&map, SimOptions::default());\n            Ok(\"map changed, blank simulation\".to_string())\n        }\n        \"/sim/get-time\" => Ok(sim.time().to_string()),\n        \"/sim/goto-time\" => {\n            let t = Time::parse(get(\"t\")?)?;\n            if t <= sim.time() {\n                bail!(\"{} is in the past. call /sim/reset first?\", t)\n            } else {\n                let dt = t - sim.time();\n                sim.timed_step(map, dt, &mut None, &mut Timer::new(\"goto-time\"));\n                Ok(format!(\"it's now {}\", t))\n            }\n        }\n        \"/sim/new-person\" => {\n            let input: ExternalPerson = abstutil::from_json(body)?;\n            for trip in &input.trips {\n                if trip.departure < sim.time() {\n                    bail!(\n                        \"It's {} now, so you can't start a trip at {}\",\n                        sim.time(),\n                        trip.departure\n                    )\n                }\n            }\n\n            let mut scenario = Scenario::empty(map, \"one-shot\");\n            scenario.people = ExternalPerson::import(map, vec![input], false)?;\n            let mut rng = XorShiftRng::seed_from_u64(load.rng_seed);\n            sim.instantiate(&scenario, map, &mut rng, &mut Timer::throwaway());\n            Ok(format!(\n                \"{} created\",\n                sim.get_all_people().last().unwrap().id\n            ))\n        }\n        // Traffic signals\n        \"/traffic-signals/get\" => {","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/headless/src/main.rs#L179-L215","documentation":"The /sim/new-person command validates that every trip's departure time is not before the current simulation time; the simulation can't spawn a trip in the past. It rejects the whole request if any trip departs before sim.time().","triggerScenarios":"POST /sim/new-person with an ExternalPerson JSON body where at least one trip.departure < sim.time() (e.g. after the simulation has already advanced).","commonSituations":"Replaying trip schedules recorded at time 0 after the sim has run for a while; hardcoded departure times in test scripts; clock drift between scenario generator and sim time (times in different formats/offsets).","solutions":["Clamp or shift trip departure times to be >= the current /sim/get-time value before submitting.","Reset the simulation (/sim/reset) so time returns to 0 and original departures are valid again.","Ensure your scenario generator and the sim use the same time units/format for departure."],"exampleFix":"// before\nawait post(\"/sim/new-person\", person); // departures from t=0 schedule\n// after\nconst now = parseTime(await post(\"/sim/get-time\"));\nperson.trips.forEach(t => { if (t.departure < now) t.departure = now; });\nawait post(\"/sim/new-person\", person);","handlingStrategy":"validation","validationCode":"const now = parseTime(await post(\"/sim/get-time\"));\nif (person.trips.some(t => parseTime(t.departure) < now)) throw new Error(\"trip departure is in the past\");","typeGuard":null,"tryCatchPattern":"try {\n  await post(\"/sim/new-person\", person);\n} catch (e) {\n  if (String(e).includes(\"can't start a trip at\")) {\n    const now = await post(\"/sim/get-time\");\n    person.trips.forEach(t => { if (t.departure < now) t.departure = now; });\n    await post(\"/sim/new-person\", person);\n  }\n}","preventionTips":["Clamp departures to current sim time before submission","Reset the sim before replaying recorded schedules","Use consistent time formats between generator and sim"],"tags":["simulation","time","http-api"],"backgroundTag":"invalid-argument-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"}