Skip to content

Bug: Driver export results in an error when uploaded to the driver assist page #199

Description

@kirillakovalenko

Description

Exporting a route from the Results page and then uploading that exact file to the Driver Assist page fails with an "Invalid save file format" error. The two sides use incompatible JSON shapes:

  • Export (downloadRouteJson.ts) writes a Route object — { vehicleId, driverName, stops: [{ id, address, lat, lng, sequence, capacityUsed, timeWindow, note, ... }], ... } (see results/types.ts).
  • Import (importSession.ts) only accepts a session-save envelope { version: 1, savedAt, data: { deliveries, vehicles } } or a raw optimize request { deliveries, vehicles }.

Because the exported Route shape matches neither schema, validation throws and the upload is rejected on both the Driver Assist page and the upload-route handoff path.

Goal

A user can export a route from the Results page, upload that exact file on the Driver Assist page, and have the Driver Assist screen populate with that route's stops.

Reproduction

Steps

  1. Run an optimization and open the Results page.
  2. Export a route to JSON (per-route export from the Results page).
  3. Go to the Driver Assist page (or the upload-route page) and upload the file from step 2.

Expected: Driver Assist loads the route and lists its stops (address, recipient, phone, package count, notes) as pending deliveries.
Actual: Upload is rejected with an error (e.g. "Invalid save file format." / "Please upload a valid JSON file.") and no route loads.

Environment: app/ui (Next.js web UI), branch main. Reproducible regardless of OS/browser.

Scope

In scope

  • Make the Results-page exported Route JSON a valid input for the Driver Assist importer, so the export → upload round-trip works.
  • Map the exported Route/Stop fields onto what Driver Assist renders: stop ordering (sequence), address, addresseeName → customer name, phoneNumber, capacityUsed → package count, note, and lat/lng for navigation.
  • Preserve existing accepted formats (session-save envelope and raw optimize request) so current upload paths keep working.
  • Surface a clear error only when the file genuinely isn't a recognized route/session file.

Out of scope

  • Changing the Results-page export format or filename convention (only adjust import to accept it, unless aligning the export is the cleaner fix — see open question).
  • Multi-route files / bulk upload of multiple routes in one file.
  • Mobile app import (app/mobile).
  • Redesigning the Driver Assist UI or the DriverRoute data model.

Acceptance Criteria

  • Exporting a route from the Results page and uploading that unmodified file on the Driver Assist page populates the page with the route's stops.
  • Stops appear in the correct route order with address, recipient name, phone number, package count, and notes carried over from the export.
  • Navigation/"directions" uses the stop's exported lat/lng.
  • Previously supported upload formats (session-save envelope and raw optimize request) still import successfully.
  • A genuinely invalid/unrelated JSON file still shows a clear validation error.
  • Tests cover importing an exported Results Route file (round-trip), added to the importSession test suite.

##Assignee
@hir-al-14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions