jeessy2/ddns-go · error
failed to get domain ID: %w
Error message
failed to get domain ID: %w
What it means
updateRecord wraps any failure from h.getDomainID() (which resolves a domain name to its numeric ID via the DNSMgr API) with this message. It means the domain ID lookup step failed — either an HTTP/network error in request(), a non-zero API code, or a response-parsing error inside getDomainID. The underlying cause is preserved via %w.
Source
Thrown at dns/hipmdnsmgr.go:146
}
}
}
// updateRecord 更新或创建 DNS 记录
func (h *HiPMDnsMgr) updateRecord(domain *config.Domain, ipAddr string, recordType string) error {
baseURL := h.DNS.ID
if baseURL == "" {
baseURL = hipmDnsMgrEndpoint
}
apiToken := h.DNS.Secret
if apiToken == "" {
return fmt.Errorf("API token cannot be empty")
}
// Get domain ID
domainID, err := h.getDomainID(baseURL, apiToken, domain.DomainName)
if err != nil {
return fmt.Errorf("failed to get domain ID: %w", err)
}
// Get existing record
record, err := h.getRecord(baseURL, apiToken, domainID, domain.SubDomain, recordType)
if err != nil {
return fmt.Errorf("failed to get record: %w", err)
}
ttl, _ := strconv.Atoi(h.TTL)
if ttl == 0 {
ttl = 600
}
if record != nil {
// Update existing record
return h.updateExistingRecord(baseURL, apiToken, domainID, record.ID, domain.SubDomain, recordType, ipAddr, ttl)
}
// Create new recordView on GitHub (pinned to 5874c2e666)
Solutions
- Check the domain name in your ddns-go config exactly matches a domain registered in DNSMgr (lookup is an exact string match on d.Name)
- Verify the API token (DNS.Secret) is valid — a bad token surfaces as 'failed to get domain ID: API error: ...'
- If using a self-hosted DNSMgr, confirm DNS.ID is a reachable base URL (trailing /api is stripped automatically)
- Test the endpoint manually: curl -H 'Authorization: Bearer <token>' '<base>/api/domains?page=1&pageSize=1&keyword=<domain>' and inspect the response
- Check network/proxy connectivity between the ddns-go host and the DNSMgr server
Example fix
// before (config) DNS.ID: "http://dnsmgr.internal:8080/api/" # unreachable host DNS.Secret: "" // after DNS.ID: "http://dnsmgr.internal:8080" DNS.Secret: "<valid API token>" // and ensure the configured domain matches an existing DNSMgr domain exactly
Defensive patterns
Strategy: validation
Validate before calling
// before running the DDNS provider, validate config
if dnsConf.DNS.Secret == "" {
return fmt.Errorf("DNSMgr API token (Secret) must be set")
}
if dnsConf.DNS.ID != "" {
if _, err := url.Parse(dnsConf.DNS.ID); err != nil {
return fmt.Errorf("invalid DNSMgr base URL: %w", err)
}
}
resp, err := http.Get(strings.TrimSuffix(dnsConf.DNS.ID, "/") + "/api/domains?page=1&pageSize=1")
if err != nil {
return fmt.Errorf("DNSMgr endpoint unreachable: %w", err)
}
resp.Body.Close() Prevention
- Always set a valid DNSMgr API token in DNS.Secret before enabling the provider
- Use the exact domain name as registered in DNSMgr (lookup is an exact match)
- Pre-verify the endpoint with a curl /api/domains call
- Keep DNSMgr server version compatible with the client's response schema
When it happens
Trigger: Any getDomainID failure while addUpdateDomainRecords -> updateRecord runs: network failure to the dnsmgr endpoint, invalid Bearer token causing an API error, or malformed/unexpected response data from /domains.
Common situations: Wrong Secret (API token) configured in ddns-go; DNSMgr server unreachable or self-hosted URL (DNS.ID) wrong; the domain in the config is not registered in DNSMgr (falls through to 'domain not found'); server returns a response shape the parser doesn't recognize after an API version change.
Related errors
- failed to get record: %w
- 请求 dnsla 失败: %w
- dnsla 请求失败,状态码: %d, 响应: %s
- API error: %s
- paginated query failed at page %d: %w
AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03).
Data as JSON: /api/errors/29d512bb824e035b.
Report an issue: GitHub.