{"record":{"id":"fd4bd358bf722a89","repo":"apache/beam","slug":"invalid-pos-type-t","errorCode":null,"errorMessage":"invalid pos type: %T","messagePattern":"invalid pos type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/mongodbio/id_range_tracker.go","lineNumber":63,"sourceCode":"\t\trest:       rest,\n\t\tcollection: collection,\n\t}\n}\n\n// cursorResult holds information about the next document to process from MongoDB. nextID is the ID\n// of the document. isExhausted is whether the cursor has been exhausted.\ntype cursorResult struct {\n\tnextID      any\n\tisExhausted bool\n}\n\n// TryClaim accepts a position representing a cursorResult of a document to read from MongoDB. The\n// position is successfully claimed if the tracker has not yet completed the work within its\n// restriction and the cursor has not been exhausted.\nfunc (rt *idRangeTracker) TryClaim(pos any) (ok bool) {\n\tresult, ok := pos.(cursorResult)\n\tif !ok {\n\t\trt.err = fmt.Errorf(\"invalid pos type: %T\", pos)\n\t\treturn false\n\t}\n\n\tif rt.IsDone() {\n\t\treturn false\n\t}\n\n\tif result.isExhausted {\n\t\trt.stopped = true\n\t\treturn false\n\t}\n\n\trt.claimed++\n\trt.claimedID = result.nextID\n\n\treturn true\n}\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/mongodbio/id_range_tracker.go#L45-L81","documentation":"idRangeTracker.TryClaim expects the claimed position to be a cursorResult — the position emitted when a document was read. If the runner hands back a position of any other type, the tracker records 'invalid pos type: %T' and fails the element claim. This is an internal contract violation between the reader's positions and its restriction tracker, so it usually indicates a bug or a mismatched checkpointed state, not a user data problem.","triggerScenarios":"Beam calls TryClaim with a pos that is not a cursorResult — e.g. state restored from a checkpoint saved by a different version of mongodbio, a custom/modified split or tracker implementation returning another position type, or a runner/SDK version skew.","commonSituations":"Resuming a pipeline whose checkpoint/state was written by an older mongodbio version whose position type changed; mixing SDK versions across workers in a heterogeneous cluster; locally patched reader code that emits raw ids instead of cursorResult.","solutions":["Pin a single version of the beam Go SDK (and mongodbio) across all workers and rerun the pipeline","Discard incompatible checkpoint/state and restart the pipeline from scratch","If you patched the reader, ensure TryClaim's emitted positions are always cursorResult values","Report the runner version and stack to Beam if it occurs with unmodified code (likely an SDK bug)","Check for SDK upgrade notes about mongodbio position type changes"],"exampleFix":"// before — custom position emitted as raw int64\nfn.emitPosition(ctx, int64(i))\n// after\nfn.emitPosition(ctx, cursorResult{ID: id, Cursor: int64(i)})","handlingStrategy":"type-guard","validationCode":"// before claiming, confirm state was written by a compatible SDK version\nif state.sdkVersion != currentSDKVersion() { discardStateAndRestart() }","typeGuard":"result, ok := pos.(cursorResult)\nif !ok {\n\treturn fmt.Errorf(\"expected cursorResult, got %T\", pos)\n}","tryCatchPattern":"defer func() {\n\tif r := recover(); r != nil || rt.err != nil {\n\t\tlog.Printf(\"claim failed: %v\", rt.err)\n\t}\n}()","preventionTips":["Pin one beam SDK version across all workers","Never mix checkpoint state across mongodbio versions","Do not alter position types in local patches","Report runner/SDK mismatches upstream"],"tags":["mongodb","go","beam","type-mismatch","tracker"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}