Skip to content

Commit 6ce1c98

Browse files
committed
fix: normalize auth profile inline secrets
1 parent 347b51b commit 6ce1c98

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Docs: https://docs.openclaw.ai
167167
- OpenAI-compatible providers: honor `compat.supportsTools=false` by stripping tool payload fields before dispatch to chat-only endpoints. Fixes #74664.
168168
- OpenAI-compatible providers: apply model-declared unsupported tool-schema keyword stripping to native OpenAI transport payloads and mark Fireworks Kimi K2.5 as rejecting `not` schemas. Fixes #75467.
169169
- OpenAI-compatible gateway: sanitize images supplied through request content even when the prompt text contains no image file references, preventing oversized attachment payloads from bypassing the resize/drop pipeline. Fixes #59913.
170+
- Auth profiles: normalize inline API keys and tokens loaded from `auth-profiles.json` so masked or rich-text credential artifacts fail as auth errors instead of crashing HTTP header construction. Fixes #77624.
170171
- llm-task: resolve configured model aliases before embedded dispatch so `model="gemini-flash"` and other aliases route to the intended provider instead of the agent default. Fixes #54166.
171172
- Media generation: resolve slash-containing model-only overrides like `fal-ai/flux/dev` through registered provider model metadata so FAL image/video models do not get misparsed as provider `fal-ai`. Fixes #77444.
172173
- Commands/BTW: show the `/btw` missing-question usage placeholder with brackets so outbound channel sanitization keeps it visible. Fixes #62877. Thanks @RajvardhanPatil07.

src/agents/auth-profiles/oauth.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,30 @@ describe("resolveApiKeyForProfile secret refs", () => {
357357
}
358358
});
359359

360+
it("normalizes inline api_key values from auth profiles before header use", async () => {
361+
const profileId = "openrouter:masked";
362+
const result = await resolveApiKeyForProfile({
363+
cfg: cfgFor(profileId, "openrouter", "api_key"),
364+
store: {
365+
version: 1,
366+
profiles: {
367+
[profileId]: {
368+
type: "api_key",
369+
provider: "openrouter",
370+
key: " sk-or-\u202650ec ",
371+
},
372+
},
373+
},
374+
profileId,
375+
});
376+
377+
expect(result).toEqual({
378+
apiKey: "sk-or-50ec", // pragma: allowlist secret
379+
provider: "openrouter",
380+
email: undefined,
381+
});
382+
});
383+
360384
it("resolves token tokenRef from env", async () => {
361385
const profileId = "github-copilot:default";
362386
await withEnvVar("GITHUB_TOKEN", "gh-ref-token", async () => {

src/agents/auth-profiles/oauth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from "../../plugins/provider-runtime.runtime.js";
1515
import { resolveSecretRefString, type SecretRefResolveCache } from "../../secrets/resolve.js";
1616
import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js";
17+
import { normalizeOptionalSecretInput } from "../../utils/normalize-secret-input.js";
1718
import { refreshChutesTokens } from "../chutes-oauth.js";
1819
import { log } from "./constants.js";
1920
import { resolveTokenExpiryState } from "./credential-state.js";
@@ -260,7 +261,7 @@ async function resolveProfileSecretString(params: {
260261
}
261262
}
262263

263-
return resolvedValue;
264+
return normalizeOptionalSecretInput(resolvedValue);
264265
}
265266

266267
export async function resolveApiKeyForProfile(

0 commit comments

Comments
 (0)