Normalize GitHub auth in generated pod spec for workspace secretRef#583
Merged
Normalize GitHub auth in generated pod spec for workspace secretRef#583
Conversation
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/controller/job_builder.go">
<violation number="1" location="internal/controller/job_builder.go:347">
P1: The new shell chain can hide clone failures because `--add credential.helper` runs unconditionally after `;`. Keep helper reconfiguration inside the `&&` success path.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
When a workspace has secretRef configured, set GH_CONFIG_DIR to a clean directory on the shared workspace volume so the gh CLI does not read stale auth from the container image's home directory. This works for both built-in and custom agent images without requiring image-specific entrypoint changes. Also fix the git credential helper setup to explicitly clear inherited credential helpers before setting the workspace helper, both for the clone command (-c credential.helper= to reset, then -c credential.helper='<helper>') and for the persisted repo config (--unset-all then --add). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gjkim42
added a commit
that referenced
this pull request
Mar 8, 2026
Normalize GitHub auth in generated pod spec for workspace secretRef
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.
What type of PR is this?
/kind bug
What this PR does / why we need it:
When a Workspace has
secretRefconfigured, Kelos should normalize GitHub auth in the generated pod spec so it works for both the built-in images and custom images.This PR makes two changes to
internal/controller/job_builder.go:Sets
GH_CONFIG_DIR=/workspace/.gh-configon the main agent container whenworkspace.secretRefis set. This givesgha clean config directory on the shared workspace volume, so it does not read stale auth from~/.config/gh/hosts.ymlor any image-baked home-directory state. This works for both built-in and custom images without requiring image-specific entrypoint changes.Clears inherited credential helpers before setting the workspace helper. The clone command now uses
-c credential.helper= -c credential.helper='<helper>'to first reset inherited helpers, and the persisted repo config uses--unset-allthen--addto ensure a clean state. The helper persistence now runs only after a successful clone, so a partial clone failure cannot be masked by a later config command. The same pattern is applied to the branch-setup fetch command.Which issue(s) this PR is related to:
Fixes #579
Special notes for your reviewer:
GH_CONFIG_DIRenv var is only set on the main container (not init containers), since init containers don't runghcommands.GH_CONFIG_DIRis NOT set when there is nosecretRef, so workspaces without auth injection are unaffected.GH_CONFIG_DIRenv var and the new helper script shape.make testandmake test-integrationboth pass locally after the review follow-up.Does this PR introduce a user-facing change?
Summary by cubic
Normalize GitHub auth for workspaces with
secretRefby setting a cleanghconfig dir and clearing inherited git credential helpers. Fixes #579 and ensures consistent auth for both built‑in and custom images.GH_CONFIG_DIR=/workspace/.gh-configon the main agent container whenworkspace.secretRefis present. No change for init containers or workspaces withoutsecretRef.-c credential.helper=then-c credential.helper='<helper>', and repo config uses--unset-allthen--addto persist the helper.Written for commit 2a0e39d. Summary will update on new commits.