fix: recursively pull explicitly depended services regardless of active profile - #1449
Open
vkaylee wants to merge 3 commits into
Open
fix: recursively pull explicitly depended services regardless of active profile#1449vkaylee wants to merge 3 commits into
vkaylee wants to merge 3 commits into
Conversation
p12tic
reviewed
Jun 13, 2026
| elif isinstance(depends_on, list): | ||
| dep_names.extend(depends_on) | ||
|
|
||
| # Check extends |
Collaborator
There was a problem hiding this comment.
No need for this commend and similar one above. Seems obvious from the next line.
p12tic
reviewed
Jun 13, 2026
| "db": {"image": "postgres"}, | ||
| } | ||
| services = self.compose._resolve_profiles(defined_services, {"test"}) | ||
| self.assertIn("web", services) |
Collaborator
There was a problem hiding this comment.
Better use something like self.assertEqual(sorted(list(services.keys())), ["db", "web"]). This is both clearer and harder to get wrong, especially in cases when you'd otherwise use assertNotIn.
p12tic
requested changes
Jun 13, 2026
p12tic
left a comment
Collaborator
There was a problem hiding this comment.
Sorry for delay in review. I had several small comments. Otherwise PR looks good, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor Checklist:
Please make sure to read development guidelines in CONTRIBUTING.md. Pull requests that do not
follow the guidelines WILL TAKE LONGER TO REVIEW as the first review comment will be to follow
these guidelines.
If this PR adds a new feature that improves compatibility with docker-compose, please add a link
to the exact part of compose spec that the PR touches.
For any user-visible change please add a release note to newsfragments directory, e.g.
newsfragments/my_feature.feature. See newsfragments/README.txt for more details.
newsfragments/resolve_profiles_dependencies.bugfixAll changes require additional unit tests.
tests/unit/test_resolve_profiles.py(all passing)Description
Bug:
When using
podman-compose --profile X up, if a service in profileXcontains adepends_onblock pointing to another serviceYthat is NOT part of profileX,podman-composecrashes with aKeyError: 'Y'. The filtering of profiles happened before dependency trees were validated, causing targeted dependencies to be stripped entirely from parsed compose data.Fix:
This PR updates the
_resolve_profilesmethod to recursively walk through explicitly defined dependencies (viadepends_onandextends). If an active service targets an excluded service, that target service is now securely pulled back into the active execution graph regardless of its underlying profile structure.This ensures proper fallback parity with
docker-compose's Go implementation where "explicitly depended services are always started."Testing:
Added comprehensive unit tests inside
test_resolve_profiles.pywhich validate:depends_on.extends.A->B->C).