Skip to content

podman-compose KeyError if extends references profile-gated service #1545

Description

@circuitsacul

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

services:
  base:
    profiles: [_base]
    image: docker.io/library/busybox

  app:
    extends: base
    profiles: [app]
    command: echo hello
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 <module>
    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:

$ 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions