Skip to content

dotenv parsing error should stop script #3427

@mtmail

Description

@mtmail
  1. I have an existing database called nominatim with a country import, so the default NOMINATIM_DATABASE_DSN=pgsql:dbname=nominatim or not setting NOMINATIM_DATABASE_DSN works.

  2. Create a second project directory on the same server. But have an unparsable line in the .env file

    cat ~/nominatim-test-2/.env
    NOMINATIM_DATABASE_DSN='pgsql:dbname=nominatim_test_2
    
  3. Don't run an import yet.

    $ psql -l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
    -----------+----------+----------+-------------+-------------+-----------------------
     nominatim | ubuntu   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
    
  4. Run nominatim admin --check-database. It prints a warning but continues and connects to the default database.

     ~/nominatim-test-2 $ nominatim admin --check-database
    2024-05-23 10:43:03: Python-dotenv could not parse statement starting at line 1.     <====
    2024-05-23 10:43:03: Using project directory: /home/ubuntu/nominatim-test-2
    2024-05-23 10:43:03: Checking database
    Checking database connection ... OK
    Checking database_version matches Nominatim software version ... OK
    Checking for placex table ... OK
    Checking for placex content ... OK
    Checking that tokenizer works ... OK
    

I'd argue Nominatim should treat parsing errors as fatal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions