{"record":{"id":"81e2d762d7241809","repo":"jeessy2/ddns-go","slug":"could-not-delete-all-d-records-in-a-one-request","errorCode":null,"errorMessage":"could not delete all %d records in a one request","messagePattern":"could not delete all (.+?) records in a one request","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/spaceship.go","lineNumber":191,"sourceCode":"\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))\n\t\treturn\n\t}\n\n\ttype Item struct {\n\t\tType    string `json:\"type\"`\n\t\tAddress string `json:\"address\"`\n\t\tName    string `json:\"name\"`\n\t}\n\tvar payload []Item\n\tfor _, ip := range ips {\n\t\tpayload = append(payload, Item{\n\t\t\tType:    recordType,\n\t\t\tAddress: ip,\n\t\t\tName:    domain.SubDomain,\n\t\t})\n\t}\n\tdata, err := json.Marshal(payload)\n\tif err != nil {","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/spaceship.go#L173-L209","documentation":"dns/spaceship.go deleteRecords() raises this when the number of IPs queued for deletion exceeds maxRecords, since deletion is sent as one batch request. It is a pre-flight guard in deleteRecords, called by updateRecord, preventing a partially-applied bulk delete.","triggerScenarios":"updateRecord finding len(ips) > maxRecords stale records to delete — i.e., more matching duplicate records exist than the single-request delete limit allows.","commonSituations":"Zones that accumulated many duplicate A/AAAA records (e.g., DDNS ran for years without cleanup); a bug or previous failure that created repeated records for the same subdomain.","solutions":["Manually delete duplicate records in the Spaceship dashboard to get under maxRecords","Update the library to a version that chunks deletions into multiple requests","Patch the code to delete in batches of maxRecords","Add monitoring to catch duplicate-record growth before hitting the limit"],"exampleFix":"// before\nif len(ips) > maxRecords {\n\terr = fmt.Errorf(\"could not delete all %d records in a one request\", len(ips))\n\treturn\n}\n// after (batched delete)\nfor len(ips) > 0 {\n\tbatch := ips\n\tif len(batch) > maxRecords {\n\t\tbatch = batch[:maxRecords]\n\t}\n\tif err := deleteBatch(batch); err != nil {\n\t\treturn err\n\t}\n\tips = ips[len(batch):]\n}","handlingStrategy":"validation","validationCode":"// preflight: count matching records before attempting bulk delete\nif len(ips) > maxRecords {\n\treturn fmt.Errorf(\"%d duplicate records exceed batch limit; clean up manually\", len(ips))\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"could not delete all\") {\n\tlog.Printf(\"too many records to delete in one request: %v\", err)\n\treturn err\n}","preventionTips":["Run duplicate-record cleanup regularly so deletions stay under maxRecords","Prevent duplicate creation by checking existing records before createRecord","Upgrade to a library version that chunks deletes"],"tags":["limit-exceeded","batch-delete","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"}