fix(plugins): suppress mirrored provider env warnings · openclaw/openclaw@0fbf463
vincentkoc
·
2026-05-03
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,6 +6,15 @@
|
6 | 6 | "providerAuthEnvVars": { |
7 | 7 | "brave": ["BRAVE_API_KEY"] |
8 | 8 | }, |
| 9 | +"setup": { |
| 10 | +"providers": [ |
| 11 | + { |
| 12 | +"id": "brave", |
| 13 | +"authMethods": ["api-key"], |
| 14 | +"envVars": ["BRAVE_API_KEY"] |
| 15 | + } |
| 16 | + ] |
| 17 | + }, |
9 | 18 | "uiHints": { |
10 | 19 | "webSearch.apiKey": { |
11 | 20 | "label": "Brave Search API Key", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -923,6 +923,35 @@ describe("loadPluginManifestRegistry", () => {
|
923 | 923 | ); |
924 | 924 | }); |
925 | 925 | |
| 926 | +it("does not report deprecated providerAuthEnvVars when setup providers mirror env vars", () => { |
| 927 | +const dir = makeTempDir(); |
| 928 | +writeManifest(dir, { |
| 929 | +id: "external-openai", |
| 930 | +providers: ["openai"], |
| 931 | +setup: { |
| 932 | +providers: [{ id: "openai", envVars: ["OPENAI_API_KEY"] }], |
| 933 | +}, |
| 934 | +providerAuthEnvVars: { |
| 935 | +openai: ["OPENAI_API_KEY"], |
| 936 | +}, |
| 937 | +configSchema: { type: "object" }, |
| 938 | +}); |
| 939 | + |
| 940 | +const registry = loadSingleCandidateRegistry({ |
| 941 | +idHint: "external-openai", |
| 942 | +rootDir: dir, |
| 943 | +origin: "global", |
| 944 | +}); |
| 945 | + |
| 946 | +expect(registry.diagnostics).not.toContainEqual( |
| 947 | +expect.objectContaining({ |
| 948 | +message: expect.stringContaining( |
| 949 | +"providerAuthEnvVars is deprecated compatibility metadata", |
| 950 | +), |
| 951 | +}), |
| 952 | +); |
| 953 | +}); |
| 954 | + |
926 | 955 | it("sanitizes manifest-controlled fields in provider auth compatibility diagnostics", () => { |
927 | 956 | const dir = makeTempDir(); |
928 | 957 | const lineBreak = String.fromCharCode(10); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -425,8 +425,19 @@ function pushProviderAuthEnvVarsCompatDiagnostic(params: {
|
425 | 425 | if (params.record.origin === "bundled" || !params.record.providerAuthEnvVars) { |
426 | 426 | return; |
427 | 427 | } |
| 428 | +const setupProviderEnvVars = new Map( |
| 429 | +(params.record.setup?.providers ?? []).map( |
| 430 | +(provider) => [provider.id, new Set(provider.envVars ?? [])] as const, |
| 431 | +), |
| 432 | +); |
428 | 433 | const providerIds = Object.entries(params.record.providerAuthEnvVars) |
429 | | -.filter(([providerId, envVars]) => providerId.trim() && envVars.length > 0) |
| 434 | +.filter(([providerId, envVars]) => { |
| 435 | +if (!providerId.trim() || envVars.length === 0) { |
| 436 | +return false; |
| 437 | +} |
| 438 | +const mirroredEnvVars = setupProviderEnvVars.get(providerId); |
| 439 | +return !mirroredEnvVars || envVars.some((envVar) => !mirroredEnvVars.has(envVar)); |
| 440 | +}) |
430 | 441 | .map(([providerId]) => providerId) |
431 | 442 | .toSorted((left, right) => left.localeCompare(right)); |
432 | 443 | if (providerIds.length === 0) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。