fix(ai): resolve the Kimi usage base URL from trusted env only - #3312
Merged
Conversation
normalizeBaseUrl() read KIMI_CODE_BASE_URL through $env, the merged view that
includes the caller's cwd/.env. That base becomes the usage URL
(buildUsageUrl at :40, used at :231) and the request sends
`Authorization: Bearer ${accessToken}` to it at :237, so repository content
could collect the user's Kimi access token.
Resolve through $credentialEnv, the resolver this codebase already uses for
material that must not come from the project .env. An explicit caller-supplied
base URL still takes precedence, and the launching shell plus GJC/user-owned
.env files keep working.
Regression: a child process with a controlled cwd (projectEnv is parsed at
module load) proves a planted .env cannot set the base, an inherited value still
applies, a planted .env cannot override it, and an explicit caller value stays
ahead of the environment. Reverting the resolver fails exactly the planted case.
Yeachan-Heo
approved these changes
Jul 27, 2026
Yeachan-Heo
left a comment
Owner
There was a problem hiding this comment.
Verdict: APPROVE — exact head 706632d162ed6a55fa8b3b64b4ecffbb280c717f
External successor to closed #3280 (housekeeping-only closure; original verdict MERGE_READY; smaller-radius sibling of #3278's refresh-token fix — an access-token-carrying usage endpoint — independently re-verified here).
Checks performed:
- Content identity confirmed:
git diff e23e8c3d<#3280 exact head> 706632d1<#3312 exact head> -- packages/ai/src/usage/kimi.tsis empty — byte-identical to the version #3280's review validated (tracednormalizeBaseUrl()→buildUsageUrl()→ theAuthorization: Bearerfetch, confirmed?.trim()-drop safety and byte-identical caller-precedence line, zero credential logging). - Rebase safety via three-way merge simulation: same pre-#3285 merge-base pattern as the other three PRs in this lane;
git merge-treeconfirms clean landing of onlykimi.ts(usage) + its own test/changelog files, no reversion of the merged env-trust refactor. - PR's own diff is 4 files / 109 lines, fully scoped to the usage base-URL trust boundary.
- CI terminal on exact head: 16 SUCCESS, 5 SKIPPED, 0 pending, 0 failing.
- Mergeability:
MERGEABLE, clean pergit merge-tree. - No merge performed — read-only lane.
—
[repo owner's gaebal-gajae (clawdbot) 🦞]
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.
Successor to #3280, reopened per your triage note:
#3280 could not be reopened directly — GitHub returns 422 once the head has been force-pushed — so this is a fresh PR on the same branch, rebased onto current
dev.Why it should still land
normalizeBaseUrl()readKIMI_CODE_BASE_URLthrough$env. That base becomes the usage URL (:231) and the request sendsAuthorization: Bearer <accessToken>to it (:237).Your review on #3280 reached MERGE_READY after independently reproducing the boundary with your own probe rather than reusing mine, and recorded that the surface closure was total. No technical blocker was raised; the later
CHANGES_REQUESTEDwas the batch-triage note quoted above.State on this head
Rebased onto current
dev(zero commits behind), suite re-run green after the rebase. Everything else is byte-identical to the head you reviewed.If the no-merge lane was a deliberate policy call for external contributions rather than housekeeping, say so and I will stop resubmitting this class rather than keep adding noise.