containers / containers/podman-compose
Confusing error message when malforming YAML
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**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`:
```yaml
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
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
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: ?
Contributor guide
Assessment
This issue has not been assessed yet.