{"record":{"id":"c0a3d116ba02421c","repo":"tursodatabase/turso","slug":"cannot-eval-aggregateoperator-with-uninitialized-s","errorCode":null,"errorMessage":"Cannot eval AggregateOperator with Uninitialized state","messagePattern":"Cannot eval AggregateOperator with Uninitialized state","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/incremental/aggregate_operator.rs","lineNumber":1458,"sourceCode":"    }\n\n    pub fn has_min_max(&self) -> bool {\n        !self.column_min_max.is_empty()\n    }\n\n    /// Check if this operator has any DISTINCT aggregates or plain DISTINCT\n    pub fn has_distinct(&self) -> bool {\n        !self.distinct_columns.is_empty() || self.is_distinct_only\n    }\n\n    fn eval_internal(\n        &mut self,\n        state: &mut EvalState,\n        cursors: &mut DbspStateCursors,\n    ) -> IOResultOr<(Delta, ComputedStates)> {\n        match state {\n            EvalState::Uninitialized => {\n                panic!(\"Cannot eval AggregateOperator with Uninitialized state\");\n            }\n            EvalState::Init { deltas } => {\n                // Aggregate operators only use left_delta, right_delta must be empty\n                assert!(\n                    deltas.right.is_empty(),\n                    \"AggregateOperator expects right_delta to be empty\"\n                );\n\n                if deltas.left.changes.is_empty() {\n                    *state = EvalState::Done;\n                    return Ok(IOResult::Done((Delta::new(), HashMap::default())));\n                }\n\n                let mut groups_to_read = BTreeMap::new();\n                for (row, _weight) in &deltas.left.changes {\n                    let group_key = self.extract_group_key(&row.values);\n                    let group_key_str = Self::group_key_to_string(&group_key);\n                    groups_to_read.insert(group_key_str, group_key);","sourceCodeStart":1440,"sourceCodeEnd":1476,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/core/incremental/aggregate_operator.rs#L1440-L1476","documentation":"AggregateOperator.eval is a state machine that must be driven from Initialized/Ready states; reaching eval with EvalState::Uninitialized means the caller skipped the initialization step of the incremental (DBSP-style) evaluation. This is an internal invariant panic in the Turso engine, not an error a SQL user should normally see.","triggerScenarios":"A bug in the incremental query engine's evaluation driver: eval is called on an AggregateOperator whose EvalState was never initialized (e.g. Init step skipped after a cursor/IO interruption path).","commonSituations":"Engine development or fuzzing of incremental view maintenance; running an experimental incremental build where an aggregate over a delta path hits an untested state transition.","solutions":["File a bug with the query that triggered it; this is an internal engine invariant violation.","Upgrade to a newer Turso build where the incremental aggregation state machine may be fixed.","As a workaround, disable incremental view maintenance / use a regular query plan instead of the incremental operator.","If developing the engine, ensure the driver always transitions EvalState from Uninitialized via the Init path before calling eval."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust: this is a panic, not a catchable error; guard at process/test boundary\nlet result = std::panic::catch_unwind(|| run_incremental_query(query));\nmatch result {\n    Ok(v) => v,\n    Err(_) => run_regular_query(query), // fallback to non-incremental plan\n}","preventionTips":["Keep the engine build up to date; incremental aggregation is experimental.","Report reproducing queries to Turso maintainers immediately.","Avoid enabling incremental view maintenance on production-critical paths until stable."],"tags":["rust","incremental","internal-panic","state-machine"],"backgroundTag":"internal-invariant-violation","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-09-06T07:15:26.990Z","contentChangedAt":"2026-09-06T07:15:26.990Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}