Skip to content

fix(docker_compose): support folded scalar and docker.io-prefixed image values#15100

Merged
thavaahariharangit merged 8 commits into
mainfrom
harry/fix-docker-compose-folded-scalar-image-update
May 22, 2026
Merged

fix(docker_compose): support folded scalar and docker.io-prefixed image values#15100
thavaahariharangit merged 8 commits into
mainfrom
harry/fix-docker-compose-folded-scalar-image-update

Conversation

@thavaahariharangit
Copy link
Copy Markdown
Contributor

@thavaahariharangit thavaahariharangit commented May 21, 2026

What are you trying to accomplish?

Resolves #13351

Adds support in the docker_compose file updater for image values written as folded/literal YAML block scalars (e.g. image: >- on its own line) and for values explicitly prefixed with docker.io/. Previously these forms were not matched by the updater’s replacement regex, causing the update to fail with Expected content to change! and preventing a PR from being created.

Anything you want to highlight for special attention from reviewers?

How will you know you've accomplished your goal?

Reproduced the failure in a minimal workflow: https://github.com/thavaahariharangit/docker-compose-core-issue-13351/actions/runs/26227433049/job/77178148320

Before the fix, the updater errored out and no PR was created:

Dependabot encountered '1' error(s) during execution, please check the logs for more details.
+-----------------------------------------------+
|         Dependencies failed to update         |
+---------------+---------------+---------------+
| Dependency    | Error Type    | Error Details |
+---------------+---------------+---------------+
| library/nginx | unknown_error | null          |
+---------------+---------------+---------------+

After the fix, running the updater locally against the same repo produces the expected PR:

updater | 2026/05/21 13:03:11 INFO Results:
updater | +---------------------------------------------------+
updater | |        Changes to Dependabot Pull Requests        |
updater | +---------+-----------------------------------------+
updater | | created | library/nginx ( from 1.25.4 to 1.31.0 ) |
updater | +---------+-----------------------------------------+

A regression spec covering the folded scalar image: form with a docker.io/library/nginx:<tag>@sha256:<digest> value has been added, and the full docker and docker_compose file updater specs pass.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@thavaahariharangit thavaahariharangit requested a review from a team as a code owner May 21, 2026 13:15
Copilot AI review requested due to automatic review settings May 21, 2026 13:15
@github-actions github-actions Bot added L: docker Docker containers L: docker:compose Docker Compose labels May 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Docker Compose image updates that previously failed when the image: value was expressed as a YAML folded/literal block scalar (e.g., image: >- on its own line) and when image references were explicitly prefixed with docker.io/. It updates the docker-compose updater logic and its shared YAML image replacement regex so Dependabot can correctly rewrite these forms instead of raising Expected content to change!.

Changes:

  • Extend the shared YAML image replacement logic to handle docker.io/-prefixed images and block scalar image: values.
  • Add a docker-compose updater fallback path: try the existing “dockerfile-style” replacement first, then fall back to YAML-image updating when no changes were made.
  • Add a regression fixture and spec covering a folded scalar image: with a docker.io/library/nginx:<tag>@sha256:<digest> value.
Show a summary per file
File Description
docker/lib/dependabot/shared/shared_file_updater.rb Enhances YAML image: replacement to preserve docker.io/ prefix and support folded/literal block scalar forms.
docker/lib/dependabot/docker_compose/file_updater.rb Adds a fallback strategy to update compose files via YAML logic when the existing replacement path makes no changes.
docker/spec/dependabot/docker_compose/file_updater_spec.rb Adds a regression spec for folded-scalar image: values (with docker.io/ prefix + digest).
docker/spec/fixtures/docker_compose/composefiles/folded_digest New fixture representing a folded-scalar compose image: value with docker.io/ prefix and digest.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment thread docker/lib/dependabot/docker_compose/file_updater.rb Outdated
Comment thread docker/lib/dependabot/shared/shared_file_updater.rb Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread docker/lib/dependabot/docker_compose/file_updater.rb Outdated
Comment thread docker/lib/dependabot/shared/shared_file_updater.rb Outdated
Comment thread docker/lib/dependabot/docker_compose/file_updater.rb Outdated
Drop the YAML fallback path in the docker_compose updater and revert the
shared_file_updater refactor. Folded/literal block scalar image: values
are now handled by extending the existing dockerfile-style declaration
regex with an optional YAML block scalar indicator.
@thavaahariharangit thavaahariharangit merged commit e15f8ca into main May 22, 2026
123 of 129 checks passed
@thavaahariharangit thavaahariharangit deleted the harry/fix-docker-compose-folded-scalar-image-update branch May 22, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: docker:compose Docker Compose L: docker Docker containers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to create a PR to update image in docker-compose file if image field is a block (folded style) scalar

3 participants