fix: ensure custom provider deletion targets correct runtime key by making key generation idempotent (#691)
This commit is contained in:
committed by
GitHub
Unverified
parent
1292e9f120
commit
50bcfeccfc
@@ -65,6 +65,15 @@ function shouldUseExplicitDefaultOverride(config: ProviderConfig, runtimeProvide
|
||||
|
||||
export function getOpenClawProviderKey(type: string, providerId: string): string {
|
||||
if (type === 'custom' || type === 'ollama') {
|
||||
// If the providerId is already a runtime key (e.g. re-seeded from openclaw.json
|
||||
// as "custom-XXXXXXXX"), return it directly to avoid double-hashing.
|
||||
const prefix = `${type}-`;
|
||||
if (providerId.startsWith(prefix)) {
|
||||
const tail = providerId.slice(prefix.length);
|
||||
if (tail.length === 8 && !tail.includes('-')) {
|
||||
return providerId;
|
||||
}
|
||||
}
|
||||
const suffix = providerId.replace(/-/g, '').slice(0, 8);
|
||||
return `${type}-${suffix}`;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,15 @@ const PROVIDER_KEY_ALIASES: Record<string, string> = {
|
||||
|
||||
export function getOpenClawProviderKeyForType(type: string, providerId: string): string {
|
||||
if (MULTI_INSTANCE_PROVIDER_TYPES.has(type)) {
|
||||
// If the providerId is already a runtime key (e.g. re-seeded from openclaw.json
|
||||
// as "custom-XXXXXXXX"), return it directly to avoid double-hashing.
|
||||
const prefix = `${type}-`;
|
||||
if (providerId.startsWith(prefix)) {
|
||||
const tail = providerId.slice(prefix.length);
|
||||
if (tail.length === 8 && !tail.includes('-')) {
|
||||
return providerId;
|
||||
}
|
||||
}
|
||||
const suffix = providerId.replace(/-/g, '').slice(0, 8);
|
||||
return `${type}-${suffix}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user