Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotenv parsing error should stop script #3427

Closed
mtmail opened this issue May 23, 2024 · 2 comments
Closed

dotenv parsing error should stop script #3427

mtmail opened this issue May 23, 2024 · 2 comments

Comments

@mtmail
Copy link
Collaborator

mtmail commented May 23, 2024

  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.

@lonvia
Copy link
Member

lonvia commented May 31, 2024

I agree that we should bail out. Sadly, this is not supported by our dotenv implementation. There is an open issue here.

@mtmail
Copy link
Collaborator Author

mtmail commented Jul 2, 2024

I created a PR theskumar/python-dotenv#520 for dotenv project.

@mtmail mtmail closed this as completed Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants