Fix Porkbun (and other zoneless providers) domain sync
updateDomains passed `zoneId: domain.zoneId` unconditionally. Providers with
no zone concept (Porkbun, DigitalOcean) return domains without a zoneId, so
this sent an explicit `undefined`, which model-redis' processKeys rejects
("zoneId is not string type") and aborts the whole sync with a 422. Cloudflare
was unaffected because its domains carry a real zoneId string.
DnsProvider.create's catch only re-threw UnauthorizedDnsApi and swallowed
everything else, returning undefined — so the route then crashed on
`item.id` with an opaque "Cannot read properties of undefined" instead of the
real validation error.
- Omit zoneId from the Domain payload when the provider doesn't supply one.
- Re-throw non-Unauthorized errors from create so failures surface properly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -96,12 +96,15 @@ class DnsProvider extends Table{
|
|||||||
}catch(error){
|
}catch(error){
|
||||||
if(error.name === 'UnauthorizedDnsApi'){
|
if(error.name === 'UnauthorizedDnsApi'){
|
||||||
let keys = [];
|
let keys = [];
|
||||||
console.log('Provider', Provider)
|
|
||||||
for(let key in Provider._keyMap){
|
for(let key in Provider._keyMap){
|
||||||
keys.push({'key': key, message: 'Invalid Key'})
|
keys.push({'key': key, message: 'Invalid Key'})
|
||||||
}
|
}
|
||||||
throw this.errors.ObjectValidateError(keys, "API rejected key");
|
throw this.errors.ObjectValidateError(keys, "API rejected key");
|
||||||
}
|
}
|
||||||
|
// Don't swallow other failures (e.g. a domain-sync validation error):
|
||||||
|
// returning undefined here made the route crash on `item.id` with an
|
||||||
|
// opaque message. Surface the real error to the caller instead.
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +148,11 @@ class DnsProvider extends Table{
|
|||||||
created_by: this.created_by,
|
created_by: this.created_by,
|
||||||
domain: domain.domain,
|
domain: domain.domain,
|
||||||
dnsProvider_id: this.id,
|
dnsProvider_id: this.id,
|
||||||
zoneId: domain.zoneId,
|
// Only providers with a zone concept (e.g. Cloudflare) return a
|
||||||
|
// zoneId. Porkbun/DigitalOcean don't, and passing an explicit
|
||||||
|
// `undefined` trips model-redis' type check ("zoneId is not string
|
||||||
|
// type") and aborts the whole sync — so omit it when absent.
|
||||||
|
...(domain.zoneId !== undefined ? {zoneId: domain.zoneId} : {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log('currentDomains:', currentDomains)
|
console.log('currentDomains:', currentDomains)
|
||||||
|
|||||||
Reference in New Issue
Block a user