containers / containers/podman-compose

podman-compose KeyError if extends references profile-gated service

Open Beginner friendly
#1,545 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
`podman-compose` resolves `extends` after gating services on `profile`, meaning that if a service extends another service gated out by a profile, you get a `KeyError`.

**To Reproduce**
```yaml
services:
base:
profiles: [_base]
image: docker.io/library/busybox

app:
extends: base
profiles: [app]
command: echo hello
```

```bash
COMPOSE_PROFILES=app podman-compose up
```

**Expected behavior**
It runs.

**Actual behavior**
Fails with a `KeyError`.

**Output**

```
$ podman-compose version
podman-compose version 1.6.0
podman version 5.8.4

$ podman version
Client: Podman Engine
Version: 5.8.4
API Version: 5.8.4
Go Version: go1.26.4-X:nodwarf5
Git Commit: 5431df23c742e5edea35bef34eed696f4db0106b
Built: Thu Jun 25 20:00:00 2026
Build Origin: Fedora Project
OS/Arch: linux/amd64

$ COMPOSE_PROFILES=app podman-compose up
Traceback (most recent call last):
File "/usr/lib/python3.14/site-packages/podman_compose.py", line 2234, in resolve_extends
del from_service["_deps"]
~~~~~~~~~~~~^^^^^^^^^
KeyError: '_deps'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/bin/podman-compose", line 6, in
sys.exit(main())
~~~~^^
File "/usr/lib/python3.14/site-packages/podman_compose.py", line 4969, in main
asyncio.run(async_main())
~~~~~~~~~~~^^^^^^^^^^^^^^
File "/usr/lib64/python3.14/asyncio/runners.py", line 205, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/lib64/python3.14/asyncio/runners.py", line 128, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/lib64/python3.14/asyncio/base_events.py", line 720, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/usr/lib/python3.14/site-packages/podman_compose.py", line 4964, in async_main
await podman_compose.run()
File "/usr/lib/python3.14/site-packages/podman_compose.py", line 2370, in run
self._parse_compose_file()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.14/site-packages/podman_compose.py", line 2682, in _parse_compose_file
resolve_extends(services, [name for _, name in service_names], self.environ)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/site-packages/podman_compose.py", line 2236, in resolve_extends
raise KeyError(
f"{from_service_name} not found at services.{name}.extends definition"
) from e
KeyError: 'base not found at services.app.extends definition'
```

For comparison, here is docker-compose:

```bash
$ COMPOSE_PROFILES=app podman compose up
>>>> Executing external compose provider "/usr/libexec/docker/cli-plugins/docker-compose". Please see podman-compose(1) for how to disable this message. <<<<

Attaching to app-1
app-1 | hello
app-1 exited with code 0
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the profile and extends configuration with COMPOSE_PROFILES=app podman-compose up, then inspect podman_compose.py at resolve_extends and its call from _parse_compose_file. Done means the example starts app and prints hello without the KeyError; compare the behavior with the docker-compose output shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.