{"record":{"id":"708c8ae583a82283","repo":"jeessy2/ddns-go","slug":"could-not-fetch-all-d-records-in-a-one-request","errorCode":null,"errorMessage":"could not fetch all %d records in a one request","messagePattern":"could not fetch all (.+?) records in a one request","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/spaceship.go","lineNumber":173,"sourceCode":"\n\ttype Response struct {\n\t\tItems []Item `json:\"items\"`\n\t\tTotal int    `json:\"total\"`\n\t}\n\n\tresp, err := s.request(domain, \"GET\", url.Values{\"take\": {strconv.Itoa(maxRecords)}, \"skip\": {\"0\"}}, []byte{})\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar response Response\n\terr = json.Unmarshal(resp, &response)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif response.Total > maxRecords {\n\t\terr = fmt.Errorf(\"could not fetch all %d records in a one request\", response.Total)\n\t\treturn\n\t}\n\n\tfor _, item := range response.Items {\n\t\tif item.Type == recordType && item.Name == domain.SubDomain {\n\t\t\tips = append(ips, item.Address)\n\t\t}\n\t}\n\treturn\n}\n\nfunc (s *Spaceship) deleteRecords(recordType string, domain *config.Domain, ips []string) (err error) {\n\tif len(ips) == 0 {\n\t\treturn\n\t}\n\n\tif len(ips) > maxRecords {\n\t\terr = fmt.Errorf(\"could not delete all %d records in a one request\", len(ips))","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/spaceship.go#L155-L191","documentation":"dns/spaceship.go getRecords() fails with this when the domain's total record count exceeds maxRecords, because the library fetches all DNS records in a single page and cannot guarantee completeness. It is raised before any record filtering, and propagates to updateRecord.","triggerScenarios":"updateRecord on a Spaceship domain whose account/zone has more records than maxRecords, so a single-page getRecords response cannot contain every record (response.Total > maxRecords).","commonSituations":"Domains with hundreds of legacy DNS records; shared zones managed by many services; using the library against an enterprise zone with heavy record churn.","solutions":["Reduce the number of DNS records in the zone (delete stale entries) so a single page suffices","Update the library to a version raising maxRecords or adding pagination","Use a dedicated subdomain zone with fewer records for DDNS","Fork and implement paginated fetching for large zones"],"exampleFix":"// before (library limit)\nif response.Total > maxRecords {\n\terr = fmt.Errorf(\"could not fetch all %d records in a one request\", response.Total)\n\treturn\n}\n// after (workaround: clean up zone)\n# delete stale records in Spaceship dashboard until Total <= maxRecords, then re-run","handlingStrategy":"validation","validationCode":"// cannot query Total beforehand; guard by keeping zone small\n// skip DDNS for zones known to exceed the limit\nif zoneRecordCount(domain) > maxRecords {\n\treturn fmt.Errorf(\"skip %s: zone exceeds single-request limit\", domain.DomainName)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"could not fetch all\") {\n\tlog.Printf(\"zone too large for single-page fetch: %v — reduce record count\", err)\n\treturn err\n}","preventionTips":["Periodically clean stale DNS records from the zone","Dedicate a small subdomain/zone for DDNS instead of a large shared zone","Update the library when pagination support lands"],"tags":["pagination","limit-exceeded","spaceship"],"backgroundTag":"pagination-limit-exceeded","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"}