Skip to content

Commit 9a6f783

Browse files
committed
Also filter out leaked properties on export
1 parent a71884a commit 9a6f783

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/core/config/ProviderSettingsManager.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { Mode, modes } from "../../shared/modes"
66
import { telemetryService } from "../../services/telemetry/TelemetryService"
77

88
const providerSettingsWithIdSchema = providerSettingsSchema.extend({ id: z.string().optional() })
9+
const discriminatedProviderSettingsWithIdSchema = providerSettingsSchemaDiscriminated.and(
10+
z.object({ id: z.string().optional() }),
11+
)
912

1013
type ProviderSettingsWithId = z.infer<typeof providerSettingsWithIdSchema>
1114

@@ -385,7 +388,15 @@ export class ProviderSettingsManager {
385388

386389
public async export() {
387390
try {
388-
return await this.lock(async () => providerProfilesSchema.parse(await this.load()))
391+
return await this.lock(async () => {
392+
const profiles = providerProfilesSchema.parse(await this.load())
393+
const configs = profiles.apiConfigs
394+
for (const name in configs) {
395+
// Avoid leaking properties from other providers.
396+
configs[name] = discriminatedProviderSettingsWithIdSchema.parse(configs[name])
397+
}
398+
return profiles
399+
})
389400
} catch (error) {
390401
throw new Error(`Failed to export provider profiles: ${error}`)
391402
}

0 commit comments

Comments
 (0)