{"record":{"id":"29d512bb824e035b","repo":"jeessy2/ddns-go","slug":"failed-to-get-domain-id-w","errorCode":null,"errorMessage":"failed to get domain ID: %w","messagePattern":"failed to get domain ID: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/hipmdnsmgr.go","lineNumber":146,"sourceCode":"\t\t}\n\t}\n}\n\n// updateRecord 更新或创建 DNS 记录\nfunc (h *HiPMDnsMgr) updateRecord(domain *config.Domain, ipAddr string, recordType string) error {\n\tbaseURL := h.DNS.ID\n\tif baseURL == \"\" {\n\t\tbaseURL = hipmDnsMgrEndpoint\n\t}\n\tapiToken := h.DNS.Secret\n\tif apiToken == \"\" {\n\t\treturn fmt.Errorf(\"API token cannot be empty\")\n\t}\n\n\t// Get domain ID\n\tdomainID, err := h.getDomainID(baseURL, apiToken, domain.DomainName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get domain ID: %w\", err)\n\t}\n\n\t// Get existing record\n\trecord, err := h.getRecord(baseURL, apiToken, domainID, domain.SubDomain, recordType)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get record: %w\", err)\n\t}\n\n\tttl, _ := strconv.Atoi(h.TTL)\n\tif ttl == 0 {\n\t\tttl = 600\n\t}\n\n\tif record != nil {\n\t\t// Update existing record\n\t\treturn h.updateExistingRecord(baseURL, apiToken, domainID, record.ID, domain.SubDomain, recordType, ipAddr, ttl)\n\t}\n\t// Create new record","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/hipmdnsmgr.go#L128-L164","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (config)\nDNS.ID: \"http://dnsmgr.internal:8080/api/\"  # unreachable host\nDNS.Secret: \"\"\n// after\nDNS.ID: \"http://dnsmgr.internal:8080\"\nDNS.Secret: \"<valid API token>\"\n// and ensure the configured domain matches an existing DNSMgr domain exactly","handlingStrategy":"validation","validationCode":"// before running the DDNS provider, validate config\nif dnsConf.DNS.Secret == \"\" {\n    return fmt.Errorf(\"DNSMgr API token (Secret) must be set\")\n}\nif dnsConf.DNS.ID != \"\" {\n    if _, err := url.Parse(dnsConf.DNS.ID); err != nil {\n        return fmt.Errorf(\"invalid DNSMgr base URL: %w\", err)\n    }\n}\nresp, err := http.Get(strings.TrimSuffix(dnsConf.DNS.ID, \"/\") + \"/api/domains?page=1&pageSize=1\")\nif err != nil {\n    return fmt.Errorf(\"DNSMgr endpoint unreachable: %w\", err)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["go","dns","api","network"],"backgroundTag":"domain-lookup-failed","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}