Skip to content

Conversation

@jsternberg
Copy link
Collaborator

@jsternberg jsternberg commented Sep 18, 2025

This adds an additional RequiredPaths that is primarily intended for
use with COPY --parents. This parameter specifies expected directories
or files that should exist when performing the checksum. A not found
error will be produced if one of these paths is missing.

This fixes an issue with COPY --parents where a non existent directory
that was intended to be copied would be ignored.

Fixes #4900.

@jsternberg jsternberg marked this pull request as draft September 18, 2025 20:37
@jsternberg jsternberg force-pushed the copy-parents branch 4 times, most recently from d03c28e to 8b24130 Compare September 25, 2025 19:20
@jsternberg jsternberg changed the title frontend: add required include paths to LLB and use it with --parents frontend: add required paths to LLB and use it with --parents Sep 25, 2025
@jsternberg jsternberg marked this pull request as ready for review September 25, 2025 19:21
@jsternberg jsternberg marked this pull request as draft September 25, 2025 20:50
@jsternberg
Copy link
Collaborator Author

Need to fix the tests but I think this method of fixing it is probably the easiest.

@jsternberg jsternberg force-pushed the copy-parents branch 4 times, most recently from 9e6f6ef to 2f4d2b1 Compare September 26, 2025 17:50
@jsternberg jsternberg force-pushed the copy-parents branch 3 times, most recently from 0bb04e7 to dba28b3 Compare September 26, 2025 19:48
@jsternberg jsternberg marked this pull request as ready for review September 26, 2025 20:35
@tonistiigi tonistiigi added this to the v0.26.0 milestone Oct 8, 2025
Wildcard bool
IncludePatterns []string
ExcludePatterns []string
RequiredPaths []string
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why this needs to take paths, instead of just being boolean? If it is boolean then I guess if no paths match then it returns a constant "zero checksum" that would be possible to check on the caller side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm a little fuzzy on why I went this direction exactly compared to the boolean, but I think there were two reasons.

  1. The error message that gave the path was really difficult to figure out without putting the paths explicitly.
  2. Wildcards complicated the boolean method because the correct prefix wasn't necessarily trivial to determine from the checksum path.

Adding the required paths as an explicit argument took away the guesswork involved with this. The main problem is we needed information both about the pivot point and the non-wildcard section of the pattern to determine which path we needed so it wasn't as simple as just saying "if things are empty it's invalid" because the directory being empty could still be valid.

This adds an additional `RequiredPaths` that is primarily intended for
use with `COPY --parents`. This parameter specifies expected directories
or files that should exist when performing the checksum. A not found
error will be produced if one of these paths is missing.

This fixes an issue with `COPY --parents` where a non existent directory
that was intended to be copied would be ignored.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@tonistiigi tonistiigi merged commit 101d754 into moby:master Oct 22, 2025
168 of 169 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

copy --parents silently ignores nonexistent paths

2 participants