Skip to content

Run the binding generator container as the invoking user - #60

Merged
cloudsmith-iduffy merged 1 commit into
masterfrom
fix/generate-as-invoking-user
Jul 30, 2026
Merged

Run the binding generator container as the invoking user#60
cloudsmith-iduffy merged 1 commit into
masterfrom
fix/generate-as-invoking-user

Conversation

@cloudsmith-iduffy

Copy link
Copy Markdown
Contributor

The Update API bindings workflow has failed on every run since it was added (latest run):

removed '.travis.yml'
removed 'git_push.sh'
rm: cannot remove 'test/api_user_test.go': Permission denied
rm: cannot remove 'test/api_vulnerabilities_test.go': Permission denied
...
[generate] ERROR task failed

Cause

bin/generate runs openapitools/openapi-generator-cli as 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 — but test/ is created by the container, so on Linux it lands root-owned. The post-generation rm -rfv test/ runs on the host as the unprivileged runner user, 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, plus HOME=/tmp since the mapped uid has no home directory in the image.

Verification

  • ./bin/generate run locally with the change: generator completes, test/ is removed cleanly, go build ./... passes.
  • Generated output is identical to the committed bindings apart from the API version header (1.1288.11.1321.5) and one maxLength spec change — the change does not affect generation itself.
  • Confirmed the image's entrypoint does not re-escalate: id inside the container reports the mapped uid, and files it creates carry that uid.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings July 30, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@cloudsmith-iduffy
cloudsmith-iduffy merged commit 39e695e into master Jul 30, 2026
2 checks passed
@cloudsmith-iduffy
cloudsmith-iduffy deleted the fix/generate-as-invoking-user branch July 30, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants