Skip to content

fix(ai): resolve the Kimi usage base URL from trusted env only - #3312

Merged
Yeachan-Heo merged 1 commit into
Yeachan-Heo:devfrom
10kH:fix/kimi-usage-baseurl-trust
Jul 27, 2026
Merged

fix(ai): resolve the Kimi usage base URL from trusted env only#3312
Yeachan-Heo merged 1 commit into
Yeachan-Heo:devfrom
10kH:fix/kimi-usage-baseurl-trust

Conversation

@10kH

@10kH 10kH commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Successor to #3280, reopened per your triage note:

Legacy/open batch triage: closing without merge in this lane. Reopen with an updated review request if this should still land.

#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() read KIMI_CODE_BASE_URL through $env. That base becomes the usage URL (:231) and the request sends Authorization: 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_REQUESTED was 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.

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 Yeachan-Heo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.ts is empty — byte-identical to the version #3280's review validated (traced normalizeBaseUrl()buildUsageUrl() → the Authorization: Bearer fetch, 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-tree confirms clean landing of only kimi.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 per git merge-tree.
  • No merge performed — read-only lane.


[repo owner's gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo
Yeachan-Heo merged commit 3d4d74c into Yeachan-Heo:dev Jul 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants