Skip to content

fix(#7089): use standard token resolution in lookupAppID - #7091

Merged
ifireball merged 3 commits into
mainfrom
agent/7089-mint-gh-auth-fallback
Sep 8, 2026
Merged

fix(#7089): use standard token resolution in lookupAppID#7091
ifireball merged 3 commits into
mainfrom
agent/7089-mint-gh-auth-fallback

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

lookupAppID in internal/cli/mint.go had its own inline token resolution that only checked GH_TOKEN and GITHUB_TOKEN env vars. This PR replaces it with a call to the shared resolveToken() function, which adds gh auth token as a third fallback — matching the resolution chain used by every other GitHub-calling command.

Related Issue

Fixes #7089

Changes

  • Replace inline env-var checks in lookupAppID with a call to resolveToken() via a testable package-level variable (lookupTokenFn)
  • Treat resolveToken() errors as "proceed unauthenticated" since the /apps/{slug} endpoint is public
  • Update the rate-limit error message to mention gh auth login as a recovery option
  • Add TestLookupAppID_UsesResolveTokenFallback to verify the fallback path
  • Update existing unauthenticated tests to use withNoToken helper for deterministic behavior

Testing

  • All TestLookupAppID_* tests pass (10 tests including new one)
  • Broader TestMintDeploy* and TestResolveToken* tests pass
  • go vet ./internal/cli/... passes
  • gofmt passes
  • Patch coverage for lookupAppID is 85.7% (above 80% threshold)

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes)
  • Commits are signed off (DCO) — human and human-directed agent sessions only
  • I wrote this contribution myself and can explain all changes in it

Closes #7089

Post-script verification

  • Branch is not main/master (agent/7089-mint-gh-auth-fallback)
  • Secret scan passed (gitleaks — 3371a4efd48cf13cf3cb756ec71a58dc80b5091e..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

lookupAppID had its own inline token resolution that only checked
GH_TOKEN and GITHUB_TOKEN env vars. The shared resolveToken function
in the same package adds gh auth token as a third fallback, matching
the resolution chain used by every other GitHub-calling command.

Replace the inline env-var checks with a call to resolveToken via a
testable package-level variable (lookupTokenFn). Since the /apps/{slug}
endpoint is public, a resolution error is treated as proceed
unauthenticated rather than a hard failure.

Closes #7089
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner September 8, 2026 07:28
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Sep 8, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 8, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:30 AM UTC · Completed 7:43 AM UTC

Commit: 973b78b · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.84

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Sep 8, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 8, 2026

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Tier 1 signals are unchanged from prior review (small 2-file, bot-authored, well-tested fix scoring 1.0); Tier 2 confirms persistent high-churn and fix-heavy history on both mint.go and mint_test.go, yielding Tier 2 composite ~2.71; weighted composite 1.65 rounds to 2 (moderate), consistent with prior score.

Previous run

Risk Assessment: moderate (2/5)

Details

Tier 1 signals are unchanged from prior review (small, well-tested, bot-authored fix scoring 1.0); Tier 2 confirms high-churn, fix-heavy history (mint.go: 19 commits/30d, 36 fix commits/90d), elevating Tier 2 composite to ~2.9 and keeping weighted composite at 1.66, rounding to 2 (moderate) — consistent with prior score of 2.

Previous run (2)

Risk Assessment: moderate (2/5)

Details

Small, well-tested bot-authored bug fix in a high-churn file that has seen prior fixes to the same function, yielding moderate risk overall.

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 8, 2026

Copy link
Copy Markdown

Looks good to me

Previous run

Looks good to me

Previous run (2)

Review

Findings

Low

  • [test adequacy] internal/cli/mint_test.go:2422 — The TestLookupAppID_RateLimit test asserts Contains(err.Error(), "set GH_TOKEN or GITHUB_TOKEN") but does not verify the newly added gh auth login suggestion. The old substring still matches (it is a prefix of the new message), so the test passes but does not validate the new remediation text.
    Remediation: Add assert.Contains(t, err.Error(), "gh auth login", "unauthenticated rate limit error should suggest gh auth login") in the TestLookupAppID_RateLimit test.

  • [code organization] internal/cli/mint_test.go:2514TestLookupAppID_UsesResolveTokenFallback restores lookupTokenFn with defer (line 2514), while the withNoToken helper introduced in this same PR uses t.Cleanup for the identical operation (line 2329). The two restoration mechanisms for the same package-level var are inconsistent within the same PR.
    Remediation: Replace the inline defer func() { lookupTokenFn = orig }() with t.Cleanup(func() { lookupTokenFn = orig }) to match the pattern established by withNoToken.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-coder

fullsend-ai-coder Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 7:45 AM UTC · Completed 7:52 AM UTC

Commit: 973b78b · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $0.70

Add assertion to TestLookupAppID_RateLimit verifying the unauthenticated
rate-limit error includes the "gh auth login" remediation text. The
existing "set GH_TOKEN or GITHUB_TOKEN" assertion is a prefix of the new
message and passes without validating the newly added suggestion.

Note: pre-commit hooks were not run. pre-commit could not complete
(infrastructure failure), and hooks were run directly instead.

Addresses #7091
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (bot-triggered)

Added missing test assertion for the gh auth login suggestion in the unauthenticated rate-limit error message, as identified by the reviewer

Fixed (1):

  1. TestLookupAppID_RateLimit does not verify the newly added gh auth login suggestion (internal/cli/mint_test.go): Added assert.Contains(t, err.Error(), "gh auth login", ...) to verify the unauthenticated rate-limit error includes the new remediation text

Tests: passed

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 8, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:54 AM UTC · Completed 8:05 AM UTC

Commit: a3fcaf0 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.63

@fullsend-ai-review
fullsend-ai-review Bot dismissed their stale review September 8, 2026 08:05

Superseded by updated review

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Sep 8, 2026
@ifireball

Copy link
Copy Markdown
Member

/fs-fix

@fullsend-ai-coder

fullsend-ai-coder Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 9:25 AM UTC · Completed 9:32 AM UTC

Commit: a3fcaf0 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $0.98

Replace defer-based lookupTokenFn restoration in
TestLookupAppID_UsesResolveTokenFallback with t.Cleanup to match the
pattern established by the withNoToken helper in the same PR.

Note: pre-commit hooks were not run. pre-commit could not complete
(infrastructure failure), and hooks were run directly instead (gofmt,
go vet passed).

Addresses #7091
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 2 (human-triggered)

Addressed code organization finding: replaced defer-based lookupTokenFn restoration with t.Cleanup in TestLookupAppID_UsesResolveTokenFallback for consistency with the withNoToken helper pattern

Fixed (1):

  1. Inconsistent cleanup pattern: TestLookupAppID_UsesResolveTokenFallback uses defer while withNoToken uses t.Cleanup for the same lookupTokenFn restoration (internal/cli/mint_test.go): Replaced defer func() { lookupTokenFn = orig }() with t.Cleanup(func() { lookupTokenFn = orig }) to match the pattern established by the withNoToken helper in the same PR

Tests: passed

Next steps:

  • /fs-review — request a re-review of the changes
  • /fs-fix <your instruction> — run another fix pass with specific guidance
  • Push commits directly — review re-runs automatically on push
    Updated by fullsend fix agent

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 8, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 9:34 AM UTC · Completed 9:48 AM UTC

Commit: da1a04f · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.54

@ifireball
ifireball added this pull request to the merge queue Sep 8, 2026
@fullsend-ai-review
fullsend-ai-review Bot dismissed their stale review September 8, 2026 09:48

Superseded by updated review

Merged via the queue into main with commit 5056cb6 Sep 8, 2026
41 checks passed
@ifireball
ifireball deleted the agent/7089-mint-gh-auth-fallback branch September 8, 2026 10:00
@fullsend-ai-retro

fullsend-ai-retro Bot commented Sep 8, 2026

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 10:02 AM UTC · Completed 10:12 AM UTC

Commit: da1a04f · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.50

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #7091 — use standard token resolution in lookupAppID

Overall assessment: The workflow performed well end-to-end. Issue #7089 went from filing to merged PR in under 3 hours, with accurate triage ($1.04, 5 min), clean code generation ($4.63, 11 min), and legitimate review findings. However, a gap in the review→fix→re-review cycle caused unnecessary human intervention and added ~$8 in avoidable agent cost.

What went well

  • Triage agent correctly identified the root cause (inline token resolution bypassing shared resolveToken()) and recommended the exact fix within 5 minutes.
  • Code agent produced a clean, well-tested implementation in 11 minutes — testable lookupTokenFn variable, withNoToken helper, updated error message, and 85.7% patch coverage.
  • Review agent caught two legitimate LOW-severity issues on the first pass: a missing assertion for the new "gh auth login" suggestion, and a defer vs t.Cleanup inconsistency.

What went wrong

The fix agent's first iteration fixed only Finding 1 (missing assertion) and silently dropped Finding 2 (defer vs t.Cleanup). This appears related to the delivery channel split: Finding 1 ended up in the review body text (because GitHub returned HTTP 422 when the review agent tried to post it inline), while Finding 2 was posted as a successful inline diff comment. The fix agent processed the review body but not the inline comments.

More critically, Review 2 — triggered by the fix commit — declared "looks good to me" without re-flagging the still-unfixed Finding 2. This left the inline comment sitting unresolved for ~1.5 hours until human reviewer ifireball noticed it and manually triggered /fs-fix at 09:23 UTC.

Evidence for existing issues

Cost breakdown

Stage Cost Notes
Triage $1.04 Accurate root-cause identification
Code $4.63 Clean implementation, good test coverage
Review 1 $4.84 Found 2 legitimate LOW findings
Fix 1 (bot) $0.70 Fixed 1 of 2 findings
Review 2 $2.63 Zero findings, missed unfixed Finding 2
Fix 2 (human) $0.98 Fixed remaining finding after human /fs-fix
Review 3 $4.54 Zero findings, confirmed clean state
Total $19.36 Reviews 2+3 ($7.17) were avoidable if Finding 2 had been fixed in iteration 1

Proposals filed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mint deploy --pem-dir ignores tokens from local gh authentication

1 participant