{"record":{"id":"368c6b82ce1fc23a","repo":"t8y2/dbx","slug":"continuation-does-not-match-request","errorCode":null,"errorMessage":"Continuation does not match request","messagePattern":"Continuation does not match request","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/zookeeper/operations.go","lineNumber":292,"sourceCode":"\t\treturn listResponse{}, err\n\t}\n\troot := normalizePath(request.Prefix)\n\trecursive := true\n\tif request.Recursive != nil {\n\t\trecursive = *request.Recursive\n\t}\n\tlimit := request.Limit\n\tif limit < 1 {\n\t\tlimit = defaultListLimit\n\t}\n\tcursor := listCursor{Root: root, Recursive: recursive}\n\tif strings.TrimSpace(request.Continuation) != \"\" {\n\t\tdecoded, err := decodeCursor(request.Continuation)\n\t\tif err != nil {\n\t\t\treturn listResponse{}, err\n\t\t}\n\t\tif decoded.Root != root || decoded.Recursive != recursive {\n\t\t\treturn listResponse{}, errors.New(\"Continuation does not match request\")\n\t\t}\n\t\tcursor = decoded\n\t}\n\texists, _, err := client.Exists(root)\n\tif err != nil {\n\t\treturn listResponse{}, err\n\t}\n\tif !exists {\n\t\treturn listResponse{Keys: []map[string]any{}, Continuation: nil}, nil\n\t}\n\tvar paths []string\n\tif recursive {\n\t\tpaths, err = listRecursive(client, root)\n\t} else {\n\t\tpaths, err = listDirectChildren(client, root)\n\t}\n\tif err != nil {\n\t\treturn listResponse{}, err","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/zookeeper/operations.go#L274-L310","documentation":"listPrefix supports cursor-based pagination. A continuation token encodes the root path and whether listing is recursive (via decodeCursor). If the decoded cursor's Root or Recursive flag differs from the current request, the token cannot be applied to this query and 'Continuation does not match request' is returned.","triggerScenarios":"Calling listPrefix with a Continuation obtained from a different root path, or with a Recursive value different from the request that produced the token (e.g. token from a recursive list reused for a flat list, or from another prefix). Raised in agents/drivers/zookeeper/operations.go:292.","commonSituations":"Client-side pagination loop that changes the prefix or Recursive flag between pages; reusing a stored cursor after the user changed search parameters; mixing cursors between two concurrent lists; serialization bugs truncating/corrupting the cursor (though that usually errors in decodeCursor first).","solutions":["Restart listing from the first page with the new parameters instead of passing the old continuation.","Keep the root and Recursive flag identical across all pages of one listing loop.","Generate a fresh token per listing session; never share tokens across different queries or users.","If cursors are persisted client-side, include the request parameters alongside and discard the token when they change."],"exampleFix":"// before\n// page 2 request changed Recursive from true to false but reused token\ncursor, err := driver.List(ctx, root, false, token)\n// after\ncursor, err := driver.List(ctx, root, true, token) // same params as page 1\n// (or drop token: driver.List(ctx, root, false, \"\"))","handlingStrategy":"validation","validationCode":"// Keep listing parameters stable across pages; reset the token when they change\nfunc (p *Pager) TokenFor(root string, recursive bool) string {\n    if p.root != root || p.recursive != recursive {\n        return \"\" // parameters changed: start a fresh listing\n    }\n    return p.continuation\n}","typeGuard":null,"tryCatchPattern":"resp, err := driver.List(ctx, root, recursive, token)\nif err != nil && strings.Contains(err.Error(), \"Continuation does not match request\") {\n    token = \"\" // stale cursor: restart listing from the first page\n    resp, err = driver.List(ctx, root, recursive, token)\n}","preventionTips":["Store root+recursive alongside the cursor and invalidate on change","Never reuse continuation tokens across different list queries","Generate fresh tokens per pagination session/user","Handle parameter changes in UI by resetting pagination state"],"tags":["pagination","zookeeper","cursor","validation"],"backgroundTag":"invalid-pagination-cursor","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}