{"record":{"id":"3fb5fb6692fefe36","repo":"t8y2/dbx","slug":"invalid-lease-continuation-s","errorCode":null,"errorMessage":"invalid lease continuation: %s","messagePattern":"invalid lease continuation: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/etcd-go/lease.go","lineNumber":181,"sourceCode":"\nvar errLeaseListDeadline = errors.New(\"ETCD_LEASE_LIST_TIMEOUT\")\n\nfunc isDeadlineError(err error) bool {\n\treturn errors.Is(err, context.DeadlineExceeded) || status.Code(err) == codes.DeadlineExceeded\n}\n\nfunc isLeaseListFallbackError(err error) bool {\n\tif errors.Is(err, errLeaseListDeadline) || errors.Is(err, context.DeadlineExceeded) {\n\t\treturn true\n\t}\n\tcode := status.Code(err)\n\treturn code == codes.Unimplemented || code == codes.DeadlineExceeded\n}\n\nfunc parseUnsignedLong(value string) (uint64, error) {\n\tparsed, err := strconv.ParseUint(value, 10, 64)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"invalid lease continuation: %s\", value)\n\t}\n\treturn parsed, nil\n}\n\nfunc leasePageIDs(leaseIDs []uint64, afterLeaseID *uint64, fetchLimit int) []uint64 {\n\tsorted := make([]uint64, len(leaseIDs))\n\tcopy(sorted, leaseIDs)\n\tsort.Slice(sorted, func(i, j int) bool { return sorted[i] < sorted[j] })\n\tresult := []uint64{}\n\tfor _, id := range sorted {\n\t\tif afterLeaseID != nil && id <= *afterLeaseID {\n\t\t\tcontinue\n\t\t}\n\t\tif len(result) >= fetchLimit {\n\t\t\tbreak\n\t\t}\n\t\tresult = append(result, id)\n\t}","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/etcd-go/lease.go#L163-L199","documentation":"parseUnsignedLong parses the continuation token used to page through leases into a uint64. If the token string is not a valid base-10 unsigned 64-bit integer, it fails with this error. The continuation value is expected to be a raw lease ID emitted by a previous leaseList page, so this error means the token is malformed or was never a lease ID.","triggerScenarios":"leaseList called with an afterLeaseID/continuation string that is empty, contains non-digit characters, has a sign or decimal point, exceeds uint64 range, or is an opaque/op-echo token from a different API.","commonSituations":"Client stored the continuation as a JSON object or base64 and passed the whole blob back; truncation/URL-encoding corrupted the token; passing a key or revision instead of a lease ID as the continuation; cross-driver paging tokens mixed up.","solutions":["Pass back the continuation token exactly as returned by the previous leaseList page, unmodified.","If constructing manually, supply a decimal string of a uint64 lease ID (e.g. \"7587868030128843137\").","Strip any URL-encoding, quotes, or whitespace before parsing; base64-decode only if your wrapper layer encoded it.","Restart pagination without a continuation token to fetch the first page, then resume with the fresh token."],"exampleFix":"// before\nparseUnsignedLong(\"page-2\") // not a uint64\n// after\nparseUnsignedLong(\"7587868030128843137\") // lease ID from previous page","handlingStrategy":"validation","validationCode":"func validContinuation(token string) bool {\n\tif token == \"\" {\n\t\treturn false\n\t}\n\t_, err := strconv.ParseUint(token, 10, 64)\n\treturn err == nil\n}\n// if afterLeaseID != \"\" && !validContinuation(afterLeaseID) { reject before calling leaseList }","typeGuard":null,"tryCatchPattern":"resp, err := driver.LeaseList(continuation)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"invalid lease continuation\") {\n\t\t// token unusable: restart pagination from the first page\n\t\tresp, err = driver.LeaseList(\"\")\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n}","preventionTips":["Treat continuation tokens as opaque; echo back exactly what the server returned.","Store tokens in lossless containers (strings in JSON, not numbers that can overflow or reformat).","Avoid URL-encoding or wrapping tokens in envelopes that add prefixes/suffixes.","Don't mix pagination tokens between drivers or endpoints."],"tags":["parsing","pagination","etcd","lease"],"backgroundTag":"invalid-continuation-token","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}