{"record":{"id":"3a15828f0cd8a9af","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-read-value-from-the-column-of","errorCode":null,"errorMessage":"Failed to read value from the `{}` column of `{}` for table_id `{}`","messagePattern":"Failed to read value from the `(.+?)` column of `(.+?)` for table_id `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/engine/src/sql/ast.rs","lineNumber":62,"sourceCode":"\n    fn rls_rules_for_table(&self, table_id: TableId) -> anyhow::Result<Vec<Box<str>>> {\n        self.tx\n            .iter_by_col_eq(\n                ST_ROW_LEVEL_SECURITY_ID,\n                StRowLevelSecurityFields::TableId,\n                &AlgebraicValue::from(table_id),\n            )?\n            .map(|row| {\n                row.read_col::<AlgebraicValue>(StRowLevelSecurityFields::Sql)\n                    .with_context(|| {\n                        format!(\n                            \"Failed to read value from the `{}` column of `{}` for table_id `{}`\",\n                            \"sql\", \"st_row_level_security\", table_id\n                        )\n                    })\n                    .and_then(|sql| {\n                        sql.into_string().map_err(|_| {\n                            anyhow::anyhow!(format!(\n                                \"Failed to read value from the `{}` column of `{}` for table_id `{}`\",\n                                \"sql\", \"st_row_level_security\", table_id\n                            ))\n                        })\n                    })\n            })\n            .collect::<anyhow::Result<_>>()\n    }\n}\n\nimpl<'a, T> SchemaViewer<'a, T> {\n    pub fn new(tx: &'a T, auth: &'a AuthCtx) -> Self {\n        Self { tx, auth }\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":78,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/engine/src/sql/ast.rs#L44-L78","documentation":"While collecting row-level-security rules, SchemaViewer::rls_rules_for_table read the sql column of st_row_level_security but the AlgebraicValue was not a string (into_string() failed). A row exists for the table_id, yet the column value's type does not match the String layout the reader expects.","triggerScenarios":"SQL query planning invoking rls_rules_for_table on a table whose st_row_level_security row's Sql column holds a non-string value; system-table layout drift after a version upgrade; st_row_level_security rows written by anything other than the current engine version.","commonSituations":"Opening a database created by an older SpacetimeDB version whose st_row_level_security schema differs; corrupted system table pages; manual or out-of-band writes into st_* system tables.","solutions":["Inspect the st_row_level_security rows for the table_id named in the message and check the actual type of the sql column","If the database predates a system-table layout change, recreate or migrate it with the current version","Never write to st_* system tables directly; go through the engine's DDL/RLS APIs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match viewer.rls_rules_for_table(table_id) {\n    Ok(rules) => rules,\n    Err(e) if e.to_string().contains(\"st_row_level_security\") => {\n        // system-table layout drift or corruption: surface with table_id context\n        log::error!(\"rls metadata unreadable for table {table_id}: {e:#}\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Upgrade databases with the same engine version that wrote them","Never write to st_* system tables directly","Add smoke tests that read RLS rules for every table after upgrades"],"tags":["rust","spacetimedb","sql","system-table","row-level-security","schema"],"backgroundTag":"column-type-mismatch","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}