{"record":{"id":"8855c051f225ba50","repo":"temporalio/temporal","slug":"expected-events-v-v-but-got-events-v-v-of","errorCode":null,"errorMessage":"expected events [%v-%v] but got events [%v-%v] of length %v: isFirstPage=%v,isLastPage=%v,pageSize=%v","messagePattern":"expected events \\[(.+?)-(.+?)\\] but got events \\[(.+?)-(.+?)\\] of length (.+?): isFirstPage=(.+?),isLastPage=(.+?),pageSize=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/history/api/get_history_util.go","lineNumber":505,"sourceCode":"\t}\n\n\tif !isLastPage {\n\t\t// estimate lastEventID based on pageSize. This is a lower bound\n\t\t// since the persistence layer counts \"batch of events\" as a single page\n\t\texpectedLastEventID = expectedFirstEventID + int64(pageSize) - 1\n\t}\n\n\tnExpectedEvents := expectedLastEventID - expectedFirstEventID + 1\n\n\tif firstEvent.GetEventId() == expectedFirstEventID &&\n\t\t((isLastPage && lastEvent.GetEventId() == expectedLastEventID && int64(eventCount) == nExpectedEvents) ||\n\t\t\t(!isLastPage && lastEvent.GetEventId() >= expectedLastEventID && int64(eventCount) >= nExpectedEvents)) {\n\t\treturn nil\n\t}\n\n\treturn softassert.UnexpectedDataLoss(logger,\n\t\t\"Incomplete history\",\n\t\tfmt.Errorf(\"expected events [%v-%v] but got events [%v-%v] of length %v: isFirstPage=%v,isLastPage=%v,pageSize=%v\",\n\t\t\texpectedFirstEventID,\n\t\t\texpectedLastEventID,\n\t\t\tfirstEvent.GetEventId(),\n\t\t\tlastEvent.GetEventId(),\n\t\t\teventCount,\n\t\t\tisFirstPage,\n\t\t\tisLastPage,\n\t\t\tpageSize))\n}\n\n// ProcessInternalRawHistory processes history in the field response.History.\n// History service can send history events in response.History.Events. In that case, process the events and move them\n// to response.Response.History. Usually this is done by history service but when history.sendRawHistoryBetweenInternalServices\n// is enabled, history service sends raw history events to frontend without any processing.\nfunc ProcessInternalRawHistory(\n\trequestContext context.Context,\n\tsaProvider searchattribute.Provider,\n\tsaMapperProvider searchattribute.MapperProvider,","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/history/api/get_history_util.go#L487-L523","documentation":"Error \"expected events [%v-%v] but got events [%v-%v] of length %v: isFirstPage=%v,isLastPage=%v,pageSize=%v\" thrown in temporalio/temporal.","triggerScenarios":"Thrown at service/history/api/get_history_util.go:505 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}