Run the binding generator container as the invoking user - #60
Merged
Conversation
The openapi-generator container ran as root, so any directory it created inside the bind-mounted repo (notably test/) was root-owned. The post-generation cleanup runs on the host as an unprivileged user and cannot unlink files in a root-owned directory, so `rm -rfv test/` failed with "Permission denied" and the Update API bindings workflow has failed on every run since it was added. macOS Docker Desktop maps bind-mount ownership to the host user, which is why this only ever broke on Linux/CI. Passing --user keeps generated files owned by the invoking user. HOME is pointed at /tmp since the mapped user has no home directory in the image. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The Update API bindings workflow has failed on every run since it was added (latest run):
Cause
bin/generaterunsopenapitools/openapi-generator-clias root with the repo bind-mounted at/local. Directories that already exist in the repo (docs/,api/) stay owned by the checkout user, so root-owned files inside them can still be replaced — buttest/is created by the container, so on Linux it lands root-owned. The post-generationrm -rfv test/runs on the host as the unprivilegedrunneruser, which has no write permission on that directory and therefore cannot unlink its contents.macOS Docker Desktop maps bind-mount ownership onto the host user regardless of the container uid, which is why this never reproduced for local runs and only broke in CI.
Fix
Pass
--user "$(id -u):$(id -g)"so generated files and directories are owned by the invoking user, plusHOME=/tmpsince the mapped uid has no home directory in the image.Verification
./bin/generaterun locally with the change: generator completes,test/is removed cleanly,go build ./...passes.1.1288.1→1.1321.5) and onemaxLengthspec change — the change does not affect generation itself.idinside the container reports the mapped uid, and files it creates carry that uid.🤖 Generated with Claude Code