{"record":{"id":"822861171e33e7a2","repo":"jeessy2/ddns-go","slug":"failed-to-parse-record-list-w","errorCode":null,"errorMessage":"failed to parse record list: %w","messagePattern":"failed to parse record list: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/hipmdnsmgr.go","lineNumber":360,"sourceCode":"\tconst pageSize = 100\n\tcurrentPage := 1\n\n\tfor {\n\t\tpath := fmt.Sprintf(\"/domains/%d/records?page=%d&pageSize=%d&subdomain=%s&type=%s\",\n\t\t\tdomainID, currentPage, pageSize, subDomain, recordType)\n\n\t\tapiResp, err := h.request(baseURL, apiToken, \"GET\", path, nil)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"paginated record query failed at page %d: %w\", currentPage, err)\n\t\t}\n\n\t\tif apiResp.Code != 0 {\n\t\t\treturn nil, fmt.Errorf(\"paginated record query API error at page %d: %s\", currentPage, apiResp.Msg)\n\t\t}\n\n\t\tvar recordList DnsMgrRecordList\n\t\tif err := json.Unmarshal(apiResp.Data, &recordList); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse record list: %w\", err)\n\t\t}\n\n\t\t// Find matching record in current page\n\t\tfor _, r := range recordList.List {\n\t\t\tif r.Name == subDomain && r.Type == recordType {\n\t\t\t\treturn &r, nil\n\t\t\t}\n\t\t}\n\n\t\t// Check if we've reached the end\n\t\tif len(recordList.List) < pageSize || (recordList.Total > 0 && currentPage*pageSize >= recordList.Total) {\n\t\t\tbreak\n\t\t}\n\n\t\tcurrentPage++\n\n\t\t// Safety limit: stop after 10 pages (1000 records)\n\t\tif currentPage > 10 {","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/hipmdnsmgr.go#L342-L378","documentation":"The records page returned Code 0 but its Data payload could not be unmarshaled into DnsMgrRecordList, so getRecord fails before it can scan the page. This indicates the provider response shape does not match the struct the library expects.","triggerScenarios":"json.Unmarshal(apiResp.Data, &recordList) errors — Data is null/empty, the provider changed the JSON schema (e.g. 'list' renamed, records as object instead of array), or an HTML error page leaked into Data.","commonSituations":"Provider API version change altering field names, gateway/proxy returning an error page with HTTP 200, pageSize/subdomain filters causing an unexpected empty payload the library doesn't handle.","solutions":["Log the raw apiResp.Data to see the actual payload shape","Compare the payload against DnsMgrRecordList/DnsMgrRecord field tags and update the structs or library version","Upgrade the library if the provider changed its schema","Check whether an intermediate proxy is rewriting error responses","Make Data tolerant (omitempty/pointer fields) and handle empty payloads explicitly"],"exampleFix":"// before\nvar recordList DnsMgrRecordList\nif err := json.Unmarshal(apiResp.Data, &recordList); err != nil {\n    return nil, fmt.Errorf(\"failed to parse record list: %w\", err)\n}\n// after\nvar recordList DnsMgrRecordList\nif len(apiResp.Data) > 0 {\n    if err := json.Unmarshal(apiResp.Data, &recordList); err != nil {\n        return nil, fmt.Errorf(\"failed to parse record list (raw=%s): %w\", string(apiResp.Data), err)\n    }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isValidRecordList(data json.RawMessage) bool {\n    if len(data) == 0 { return false }\n    var probe struct {\n        List []DnsMgrRecord `json:\"list\"`\n    }\n    return json.Unmarshal(data, &probe) == nil\n}","tryCatchPattern":"rec, err := mgr.getRecord(baseURL, token, domainID, sub, rtype)\nif err != nil && strings.Contains(err.Error(), \"failed to parse record list\") {\n    // provider schema changed; pin library version or inspect raw payload before upgrading\n    return fmt.Errorf(\"provider response format incompatible: %w\", err)\n}","preventionTips":["Pin the library version tested against the current provider API","Log raw response bodies on parse failures","Handle null/empty Data payloads explicitly","Subscribe to provider API change announcements"],"tags":["dns","json","schema","parsing"],"backgroundTag":"schema-validation-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"}