Skip to content

Fix publish short-form port mappings#13680

Open
false200 wants to merge 4 commits intodocker:mainfrom
false200:13672-publish-short-port-mapping
Open

Fix publish short-form port mappings#13680
false200 wants to merge 4 commits intodocker:mainfrom
false200:13672-publish-short-port-mapping

Conversation

@false200
Copy link
Contributor

What I did

Fixed docker compose publish so it works with short-form port mappings like ${DASHBOARD_PORT:-3000}:3000.

The issue was in the publish scan path. It was loading a non-interpolated Compose file back into types.Project, and that caused short-form port entries to fail decoding. This change keeps that path as raw YAML model data instead.

I also added:

  • a unit test for this case in pkg/compose/publish_test.go
  • an e2e regression test in pkg/e2e/publish_test.go

Related issue

Fixes #13672

(not mandatory) A picture of a cute animal, if possible in relation to what you did)

Signed-off-by: CodeLoopdroid <214800619+CodeLoopdroid@users.noreply.github.com>
@false200 false200 requested a review from a team as a code owner March 26, 2026 16:10
@false200 false200 requested review from glours and ndeloof March 26, 2026 16:10
@false200
Copy link
Contributor Author

Hi maintainers,

I looked into this and was able to reproduce it.

The failure comes from the publish scan path, not from normal Compose parsing. That path reloads a non-interpolated Compose file back into types.Project, and short form port entries like ${DASHBOARD_PORT:-3000}:3000 end up failing there with:

'services[whoami].ports[0]' expected a map or struct, got "string"

I put together a fix that keeps that path as raw YAML model data instead of rebinding it into types.Project, which makes docker compose publish accept the short form port mapping again.

I also verified it with:

  • a focused unit test
  • an e2e publish --dry-run regression test

On the patched build, the repro passes for me instead of throwing the decode error.

glours
glours previously approved these changes Mar 27, 2026
Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, thanks for the fix 🙏

@false200 false200 requested a review from glours March 27, 2026 09:29
Signed-off-by: CodeLoopdroid <214800619+CodeLoopdroid@users.noreply.github.com>
glours
glours previously approved these changes Mar 27, 2026
Signed-off-by: CodeLoopdroid <214800619+CodeLoopdroid@users.noreply.github.com>
Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback pattern in the last commit silently discards errors from LoadWithContext, any real config error would go unnoticed and fall through to the raw model path. The two paths also produce different YAML representations, making the secret scanner's behavior inconsistent.
The 3rd commit (LoadModelWithContext only) is the right direction. The sensitive data detection issue should be fixed at a higher level rather than papering over it with a fragile try/fallback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] docker compose publish rejects short-form port mapping

2 participants