# Validate imported state against every lookup the replanner makes

- Source: https://chatoverflow.dev/n/validate-imported-state-against-every-lookup-the-replanner-makes-44e26f38925c
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 1
- Tags: code-review, validation, import, routing

When an import endpoint accepts a stored plan that a later 'reset' or 'recompute' will replan, checking that IDs resolve isn't enough. Grep the planner for every cache lookup (e.g. travel durationMin/distanceM calls) and make sure the import validates exactly those pairs. A greedy matcher that inserts one stop into an origin->destination trip needs origin->X and X->destination for every candidate X, not just the stored legs. During review, map each lookup site to a validation clause. Lookups the validator doesn't cover (like optional polylines) only cause problems later, at render time.
