containers / containers/podman-compose
Unclear error when `networks`/`volumes` are accidentally indented under `services`
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When a user accidentally indents `networks` or `volumes` at the same level as service definitions (so they become services named `networks`/`volumes` instead of top-level keys), `podman-compose` fails late with a confusing `RuntimeError: missing networks: ` and a long traceback.
`docker-compose` catches the same mistake immediately with a clear schema-level message: `services.networks Additional property is not allowed`.
`podman-compose` should detect reserved keys used as service names and emit a concise, actionable error (or at least a warning) without a traceback.
**To Reproduce**
1. `docker-compose.yml`:
```yaml
services:
app:
image: busybox
networks:
- mynet
networks:
mynet:
driver: bridge
```
2. what is the sequence of commands you typed:
```bash
podman-compose -f docker-compose.yml config
```
**Expected behavior**
Something similar to `docker-compose`:
```
validating docker-compose.yml: services.networks Additional property mynet is not allowed
```
**Actual behavior**
```
Traceback (most recent call last):
File ".../podman_compose.py", line 5541, in
main()
...
File ".../podman_compose.py", line 2961, in _parse_compose_file
raise RuntimeError(f"missing networks: {missing_nets_str}")
RuntimeError: missing networks: mynet
```
The error is misleading: the network `mynet` *is* defined in the file, but it is parsed as a service because of the indentation mistake.
**Environment:**
```
Debian GNU/Linux 13 (trixie)
Python 3.13.5
podman-compose version 1.6.0
podman version 5.4.2
```
**Additional context**
`networks` is indented under `services`, so YAML parses it as a *service* named `networks` rather than a top-level `networks` section. The same happens with `volumes`, `secrets`, and `configs`.
Reserved keys that should be checked
- `networks`
- `volumes`
- `secrets`
- `configs`
Contributor guide
Research direction
Start with podman_compose.py and the _parse_compose_file path used by `podman-compose -f docker-compose.yml config`; reproduce the indentation error from the issue and trace where the misleading missing-network exception is raised. Done means an indented `networks`, `volumes`, `secrets`, or `configs` key produces a concise actionable error or warning without a traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, python
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100