{"record":{"id":"095f7eb9c9e647fd","repo":"clockworklabs/SpacetimeDB","slug":"someone-put-a-forbidden-variant-in-the-system-tabl","errorCode":null,"errorMessage":"Someone put a forbidden variant in the system table!","messagePattern":"Someone put a forbidden variant in the system table!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/datastore/src/system_tables.rs","lineNumber":1407,"sourceCode":"        read_via_bsatn(row)\n    }\n}\n\nimpl From<StConstraintRow> for ProductValue {\n    fn from(x: StConstraintRow) -> Self {\n        to_product_value(&x)\n    }\n}\n\nimpl From<StConstraintRow> for ConstraintSchema {\n    fn from(x: StConstraintRow) -> Self {\n        Self {\n            constraint_id: x.constraint_id,\n            constraint_name: x.constraint_name,\n            table_id: x.table_id,\n            data: match x.constraint_data {\n                StConstraintData::Unique { columns } => ConstraintData::Unique(UniqueConstraintData { columns }),\n                StConstraintData::Unused(_) => panic!(\"Someone put a forbidden variant in the system table!\"),\n            },\n        }\n    }\n}\n\n/// System Table [ST_ROW_LEVEL_SECURITY_NAME]\n///\n/// | table_id | sql          |\n/// |----------|--------------|\n/// | 1        | \"SELECT ...\" |\n#[derive(Debug, Clone, PartialEq, Eq, SpacetimeType)]\n#[sats(crate = spacetimedb_lib)]\npub struct StRowLevelSecurityRow {\n    pub table_id: TableId,\n    pub sql: RawSql,\n}\n\nimpl TryFrom<RowRef<'_>> for StRowLevelSecurityRow {","sourceCodeStart":1389,"sourceCodeEnd":1425,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/datastore/src/system_tables.rs#L1389-L1425","documentation":"Constraint rows read from the st_constraints system table are converted into ConstraintSchema via From<StConstraintRow> when loading schema. The StConstraintData::Unused variant is the catch-all for forbidden/unknown constraint tags, and converting it panics. Seeing this panic means a system-table row decoded to an unrecognized constraint kind: version skew between the build that wrote the data and the build reading it, or corrupted system-table data.","triggerScenarios":"Booting or loading schema for a database whose st_constraints rows contain a constraint tag that the running build maps to StConstraintData::Unused, hitting the From impl during schema load.","commonSituations":"Opening a commitlog/database written by a different spacetimedb version with renamed constraint variants; forks that added constraint variants; bit-rot in stored system tables.","solutions":["Open the database with the spacetimedb version that wrote it (or one that maps the tag), then export and reimport the data.","Check release notes for constraint-variant changes and pick a compatible version.","If it reproduces on a freshly created database, report upstream with the offending constraint row."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// wrap schema loading so an unrecognized constraint variant is reported, not fatal\nlet loaded = std::panic::catch_unwind(|| db.load_schema());\nmatch loaded {\n    Ok(schema) => schema,\n    Err(p) if panic_message(&p).contains(\"forbidden variant\") => {\n        // system table contains a constraint tag unknown to this build:\n        // reopen with the version that wrote the data, then export/reimport\n    }\n    Err(p) => std::panic::resume_unwind(p),\n}","preventionTips":["Open databases only with spacetimedb builds compatible with the version that wrote them.","Keep commitlogs backed up before upgrading across major versions.","Report unrecognized constraint variants upstream with the row contents."],"tags":["spacetimedb","system-tables","constraint","version-skew","invariant"],"backgroundTag":"system-table-invariant","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}