johanohly / AirTrail

A modern, open-source personal flight tracking system
http://airtrail.johan.ohly.dk/
GNU General Public License v3.0
276 stars 13 forks source link

Airtrail JSON import fails #131

Closed nirenjan closed 1 day ago

nirenjan commented 1 day ago

The bug

When I attempt to import airtrail.json from an Airtrail export, it fails with the following popup.

image

This happens regardless of what state Airtrail is in. I have tried to import the contents immediately after export, and also into a fresh instance of Airtrail, both times I get the same error. I see no logs in the docker container. But I do see en error message when using the browser console.

Operating System that is running AirTrail

Ubuntu

AirTrail Version

1.1.0

Your docker-compose.yml content

services:
  db:
    image: postgres:16-alpine
    restart: always
    env_file:
      - .env
    environment:
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - db_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE_NAME}"]
      interval: 5s
      timeout: 5s
      retries: 5

  airtrail:
    image: johly/airtrail:latest
    restart: always
    env_file:
      - .env
    ports:
      - 1380:3000
    depends_on:
      db:
        condition: service_healthy

volumes:
  db_data:

Your .env content

# Your domain, e.g https://example.com
# You might have to add :443 if you are using https through a reverse proxy
ORIGIN=http://XXXXXXX:1380

# The database URL used by the application.
# If you are using the provided docker-compose file, you should only change the PASSWORD_HERE
# If you are using your own database, you should change this to the correct URL
DB_URL=postgres://airtrail:XXXXXXXXXX@db:5432/airtrail

# Values below this line are only for the default provided postgres database
###################################################################################
# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
# When you change the DB_PASSWORD, you should also update the DB_URL accordingly
DB_PASSWORD=XXXXXXXXXX

# The values below this line do not need to be changed
###################################################################################
DB_DATABASE_NAME=airtrail
DB_USERNAME=airtrail

Reproduction steps

  1. Export flights using the Export menu in settings (using JSON format)
  2. Import the same exported file from the Import menu
  3. Observe error popup, and below logs

This also works with a trimmed down export JSON, attached here: airtrail.json

Relevant log output

index.MfnEzb-6.js:22 Error: [
  {
    "code": "invalid_string",
    "validation": "datetime",
    "message": "Invalid datetime",
    "path": [
      "flights",
      0,
      "departure"
    ]
  },
  {
    "code": "invalid_string",
    "validation": "datetime",
    "message": "Invalid datetime",
    "path": [
      "flights",
      0,
      "arrival"
    ]
  }
]
    at vk (index.MfnEzb-6.js:20:20983)
    at bk (index.MfnEzb-6.js:20:22011)
    at async HTMLButtonElement.h [as __click] (index.MfnEzb-6.js:22:420)

Additional information

Seems like the error is popping up here. I don't know Typescript enough to even attempt to fix this.

johanohly commented 1 day ago

Thank you again for finding and reporting all of these bugs!

This was an oversight on my part while developing v1, in which I changed the format of how timestamps are stored. The importer did not take this into account, which is why it failed.

The fix will be available in the next release.