podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

Confusing error message when malforming YAML

Open mrexodia opened this issue 2 years ago • 3 comments

Describe the bug

I copied configuration from somewhere and it was malformed. The error message I got from podman-compose was very confusing though.

To Reproduce Steps to reproduce the behavior: docker-compose.yml:

version: '3.7'

services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.6.0
    container_name: elasticsearch
    environment:
      - cluster.routing.allocation.disk.threshold_enabled=false
      - xpack.security.enabled=false
      - discovery.type=single-node
      - http.port: 9200
      - http.cors.allow-origin: http://localhost:1358,http://127.0.0.1:1358
      - http.cors.enabled: true
      - http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
      - http.cors.allow-credentials: true
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    cap_add:
      - IPC_LOCK
    volumes:
      - elasticsearch-data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
  dejavu:
      image: appbaseio/dejavu:3.6.0
      container_name: dejavu
      ports:
          - '1358:1358'
      links:
          - elasticsearch

volumes:
  elasticsearch-data:
    driver: local

podman-compose up

Expected behavior

Fail somewhat gracefully. Perhaps: Expected list of strings in 'environment', got xxx line yyy

Actual behavior

Stack trace:

podman-compose down
['podman', '--version', '']
using podman version: 4.3.1
Traceback (most recent call last):
  File "/Users/admin/.asdf/installs/python/3.11.0/bin/podman-compose", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/admin/.asdf/installs/python/3.11.0/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/podman_compose.py", line 1775, in main
    podman_compose.run()
  File "/Users/admin/.asdf/installs/python/3.11.0/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/podman_compose.py", line 1022, in run
    self._parse_compose_file()
  File "/Users/admin/.asdf/installs/python/3.11.0/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/podman_compose.py", line 1088, in _parse_compose_file
    content = normalize(content)
              ^^^^^^^^^^^^^^^^^^
  File "/Users/admin/.asdf/installs/python/3.11.0/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/podman_compose.py", line 879, in normalize
    normalize_service(service)
  File "/Users/admin/.asdf/installs/python/3.11.0/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/podman_compose.py", line 865, in normalize_service
    service[key] = norm_as_dict(service[key])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/admin/.asdf/installs/python/3.11.0/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/podman_compose.py", line 239, in norm_as_dict
    dst = [i.split("=", 1) for i in src if i]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/admin/.asdf/installs/python/3.11.0/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/podman_compose.py", line 239, in <listcomp>
    dst = [i.split("=", 1) for i in src if i]
           ^^^^^^^
AttributeError: 'dict' object has no attribute 'split'

Output

$ podman-compose version
['podman', '--version', '']
using podman version: 4.3.1
podman-composer version  1.0.3
podman --version 
podman version 4.3.1
exit code: 0

$ podman-compose up
...

Environment:

  • OS: Mac
  • podman version: 4.3.1
  • podman compose version: ?

mrexodia avatar Jan 24 '23 13:01 mrexodia

I was experiencing the same error. Best guess at the moment is that it has something to do with putting '-' when using ':' for assigning environment variables. Also perhaps the mixed syntax -- such as assigning some environment variables using '=' and some with ':'. This error went away for me when I addressed this.

briandannenmueller avatar May 16 '23 14:05 briandannenmueller

I concur with @briandannenmueller's analysis. I was working on Ollama models and I used environment variables like this:

environment:
  - OLLAMA_HOST: "0.0.0.0:11434"

I removed the hyphen and presto, it works:

environment:
  OLLAMA_HOST: "0.0.0.0:11434"

injcristianrojas avatar Jan 29 '25 14:01 injcristianrojas

Just had a similar problem due to using this syntax for defining environment variables:

environment:
  - FOO: "bar"

instead of:

environment:
  - FOO=bar

which worked fine.

Thankfully a search led me here!

jultty avatar Oct 18 '25 19:10 jultty