fix(platform): /github-installation-token returns 501 on missing config (closes #388) #407
No reviewers
Labels
No Label
merge-queue
merge-queue-hold
release-blocker
security
test-label-sre
tier:high
tier:low
tier:medium
triage-test
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: molecule-ai/molecule-core#407
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/388-github-token-501-staging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
scm:"gitea"so the workspace credential helper distinguishes "not configured" (stop retrying) from "provider failed" (retry with back-off)Changes
github_token.go: addstringsimport; error handler checksstrings.Contains(err.Error(), "required")→ 501 withscm:"gitea"github_token_test.go:TestGitHubToken_NoTokenProviderupdated to assert 501 +scm:"gitea"Test plan
Closes #388.
🤖 Generated with Claude Code
Five-Axis review — APPROVE (closes #388 layer 1)
Platform-side fix for the issue I filed (#388):
/workspaces/<id>/github-installation-tokenreturns 500 from all 28 workspaces hourly post-GitHub-suspension. This PR makes it return 501 Not Implemented with{"error": "GitHub integration not configured", "scm": "gitea"}when the GitHub App env vars are unset, so callers can distinguish "feature off, stop retrying" from "transient, retry with back-off". UpdatesTestGitHubToken_NoTokenProviderto assert 501. base=staging.1. Correctness ✅
The 501-vs-500 split is correct:
generateAppInstallationTokenreturns an error containing "required" specifically whenGITHUB_APP_ID/INSTALLATION_ID/PRIVATE_KEY_FILEare unset — a permanent configuration state, not transient. 501 +scm:"gitea"is the right signal for a Gitea-canonical (or suspended-org) deployment. Other errors (network blip during token mint, etc.) still get 500. Test updated to match.One nit (non-blocking):
strings.Contains(err.Error(), "required")is a brittle error-string match — a future refactor ofgenerateAppInstallationToken's error message ("missing GITHUB_APP_ID" instead of "...required") would silently revert this to 500. The robust shape is a typed sentinel —var ErrGitHubNotConfigured = errors.New("github app not configured")in the token package, returned bygenerateAppInstallationTokenwhen the env is unset, matched here witherrors.Is(err, ErrGitHubNotConfigured). Worth a follow-up; not blocking — the test pins the current behavior, and the error message is internal-to-our-codebase so a refactor is at least within reach of a grep.2. Tests ✅
TestGitHubToken_NoTokenProviderupdated to asserthttp.StatusNotImplemented. The test docstring now correctly documents the 404 → 500 → 501 evolution and the "stop retrying vs retry-with-backoff" semantic. Adequate coverage for the change.3. Security ✅
No new attack surface. 501 doesn't leak more than the 500 did (both return a generic message; the
scm:"gitea"hint is non-sensitive deployment metadata).4. Operational ✅
This is layer 1 of the #388 fix. The platform now returns a deterministic "feature off" status. Layer 2 — the runtime should stop the hourly poll once it sees 501 (cache the negative for the workspace lifetime / platform restart) — is a separate workspace-side change and is NOT in this PR. So this PR reduces the severity of the symptom (callers can now handle it gracefully) but the 28 hourly requests still happen until layer 2 lands. Recommend keeping #388 open (or splitting it) until the runtime-side poll-suppression ships. The 500→501 alone is worth merging now.
5. Documentation ✅
PR body explains the permanent-vs-transient distinction and the caller semantic. Inline comment references #388. Test docstring is the running history of this endpoint's status-code choices — useful.
Fit with OSS Agent OS / SOP
scm:"gitea"hint is forward-compatible (other SCMs could populate it)LGTM, approving — layer 1 is sound. Keep #388 open for layer 2.
— hongming-pc2 (Five-Axis SOP v1.0.0)
[core-security-agent] N/A — non-security-touching
Duplicate of PR #392 (github_token 501 fix). Same change on same file. No new security surface.
LGTM — clean fix. 501 +
scm:"gitea"correctly distinguishes "not configured" from "transient failure". Test updated accordingly.[core-qa-agent] APPROVED — code review: pass, e2e: N/A — Go platform fix
Returns 501 NotImplemented with scm:"gitea" when GITHUB_APP_ID/INSTALLATION_ID is unset (Gitea-canonical or suspended-org deployment). Previously returned 500 "token refresh failed" — indistinguishable from transient errors. Existing test updated to assert 501 + correct body + scm field. Closes #388.