Skip to content

detect un-decrypted env files #60

@tylergannon

Description

@tylergannon

If one runs syk up while the environment files are still in their decrypted state, the result is a somewhat cryptic failure from docker-compose.

❯ syk up
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 123, in perform_command
  File "compose/cli/command.py", line 69, in project_from_options
  File "compose/cli/command.py", line 127, in get_project
  File "compose/config/config.py", line 406, in load
  File "compose/config/config.py", line 520, in load_services
  File "compose/config/config.py", line 501, in build_services
  File "compose/config/config.py", line 501, in <listcomp>
  File "compose/config/config.py", line 493, in build_service
  File "compose/config/config.py", line 910, in finalize_service
  File "compose/config/config.py", line 695, in resolve_environment
  File "compose/config/environment.py", line 38, in env_vars_from_file
  File "site-packages/dotenv/main.py", line 318, in dotenv_values
  File "site-packages/dotenv/main.py", line 86, in dict
  File "site-packages/dotenv/main.py", line 93, in parse
  File "site-packages/dotenv/main.py", line 48, in with_warn_for_invalid_lines
  File "site-packages/dotenv/parser.py", line 235, in parse_stream
  File "site-packages/dotenv/parser.py", line 107, in __init__
  File "/Users/administrator/jenkins/workspace/dsg_compose_1.27.4/venv/lib/python3.7/codecs.py", line 322, in decode
  File "/Users/administrator/jenkins/workspace/dsg_compose_1.27.4/venv/lib/python3.7/encodings/utf_8_sig.py", line 69, in _buffer_decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe8 in position 13: invalid continuation byte
[28536] Failed to execute script docker-compose

We could either check the .env files to ensure they are plain text before calling docker-compose, or else catch a CalledProcessError that encapsulates the UnicodeDecodeError raised by dotenv when it tries to open the encrypted file.

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