{"record":{"id":"d9bbcd80b43b54fb","repo":"jeessy2/ddns-go","slug":"failed-to-get-record-w","errorCode":null,"errorMessage":"failed to get record: %w","messagePattern":"failed to get record: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/hipmdnsmgr.go","lineNumber":152,"sourceCode":"\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\n\treturn h.createRecord(baseURL, apiToken, domainID, domain.SubDomain, recordType, ipAddr, ttl)\n}\n\n// getHeaders 获取请求头\n// 参考 dnsmgr.ts 中的 getHeaders() 方法\nfunc (h *HiPMDnsMgr) getHeaders(apiToken string) map[string]string {","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/hipmdnsmgr.go#L134-L170","documentation":"updateRecord wraps any failure from h.getRecord() (which paginates /domains/{id}/records looking for an existing record for the subdomain+type) with this message. It means fetching the existing record list failed — network error, non-zero API code, or JSON parse failure in getRecord. Note: getRecord returning (nil, nil) when no record exists is NOT an error; the code then creates the record.","triggerScenarios":"Any getRecord error during addUpdateDomainRecords -> updateRecord: HTTP failure on /domains/{domainID}/records, API returning code != 0 (e.g. auth or permission problem on that domain), or response Data that doesn't unmarshal into DnsMgrRecordList {total, list}.","commonSituations":"Token lacks permission for the specific domain's records; an invalid domainID (0) was passed through after a domain lookup failure; API upgraded and record-list response shape changed so json.Unmarshal into DnsMgrRecordList fails; transient network errors mid-pagination.","solutions":["Read the wrapped cause: 'paginated record query API error' means auth/permission — fix the token or its domain permissions","Confirm the previous 'failed to get domain ID' step succeeded (a bogus domainID makes record queries fail)","Verify the API still returns {\"total\":..,\"list\":[...]} for /domains/{id}/records; adjust for API shape changes","Check connectivity/proxy for intermittent 'paginated record query failed' network causes","Retry the DDNS update — pagination spans multiple requests, so transient blips can abort it"],"exampleFix":"// before\napiToken := \"expired-token\"\n// after: regenerate the token in DNSMgr and update the ddns-go Secret\napiToken := \"<freshly generated DNSMgr API token>\"","handlingStrategy":"try-catch","validationCode":"// verify token can list records for the domain before relying on updates\nreq, _ := http.NewRequest(\"GET\", base+\"/api/domains/1/records?page=1&pageSize=1\", nil)\nreq.Header.Set(\"Authorization\", \"Bearer \"+apiToken)\nresp, err := http.DefaultClient.Do(req)\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"record endpoint unreachable or unauthorized\")\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err := provider.AddUpdateDomainRecords(); err != nil {\n    var wrapped interface{ Unwrap() error }\n    if errors.As(err, &target) && strings.Contains(err.Error(), \"API error\") {\n        // auth/permission problem: refresh token and retry once\n        refreshTokenAndRetry()\n    } else {\n        log.Printf(\"transient record lookup failure, will retry next cycle: %v\", err)\n    }\n}","preventionTips":["Grant the API token permission to read/write records on all configured domains","Fix domain-lookup failures first — an invalid domainID cascades into record query failures","Handle 'no record found' as a create path (library does this); only errors here are real failures","Monitor DDNS logs each cycle; pagination failures are often intermittent network issues"],"tags":["go","dns","api","network"],"backgroundTag":"record-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"}