mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:37:39 +00:00
fix: use effective home for legacy zai auth fallback
This commit is contained in:
@@ -174,7 +174,9 @@ describe("resolveProviderAuths key normalization", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to legacy .pi auth file for zai keys", async () => {
|
it("falls back to legacy .pi auth file for zai keys even after os.homedir() is primed", async () => {
|
||||||
|
// Prime os.homedir() to simulate long-lived workers that may have touched it before HOME changes.
|
||||||
|
os.homedir();
|
||||||
await withSuiteHome(
|
await withSuiteHome(
|
||||||
async (home) => {
|
async (home) => {
|
||||||
await writeLegacyPiAuth(
|
await writeLegacyPiAuth(
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { getCustomProviderApiKey } from "../agents/model-auth.js";
|
|||||||
import { normalizeProviderId } from "../agents/model-selection.js";
|
import { normalizeProviderId } from "../agents/model-selection.js";
|
||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
import { normalizeSecretInput } from "../utils/normalize-secret-input.js";
|
import { normalizeSecretInput } from "../utils/normalize-secret-input.js";
|
||||||
|
import { resolveRequiredHomeDir } from "./home-dir.js";
|
||||||
import type { UsageProviderId } from "./provider-usage.types.js";
|
import type { UsageProviderId } from "./provider-usage.types.js";
|
||||||
|
|
||||||
export type ProviderAuth = {
|
export type ProviderAuth = {
|
||||||
@@ -58,7 +59,12 @@ function resolveZaiApiKey(): string | undefined {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const authPath = path.join(os.homedir(), ".pi", "agent", "auth.json");
|
const authPath = path.join(
|
||||||
|
resolveRequiredHomeDir(process.env, os.homedir),
|
||||||
|
".pi",
|
||||||
|
"agent",
|
||||||
|
"auth.json",
|
||||||
|
);
|
||||||
if (!fs.existsSync(authPath)) {
|
if (!fs.existsSync(authPath)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user