{"record":{"id":"0b86e65f78ee0be4","repo":"elsa-workflows/elsa-core","slug":"sqlite-identifier-identifier-is-not-valid-for","errorCode":null,"errorMessage":"SQLite identifier '{identifier}' is not valid for physicalization.","messagePattern":"SQLite identifier '(.+?)' is not valid for physicalization\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Persistence.VNext.Sqlite/Physicalization/SqlitePhysicalizationPlanner.cs","lineNumber":54,"sourceCode":"\n        foreach (var index in policy.Indexes)\n        {\n            var indexName = Quote(index.Name);\n            var indexColumns = string.Join(\", \", index.Fields.Select(field => Quote(field)));\n            var unique = index.IsUnique ? \"UNIQUE \" : string.Empty;\n            operations.Add(new(\n                \"CreateIndex\",\n                $\"Create SQLite index {indexName} on {tableName}.\",\n                $\"CREATE {unique}INDEX IF NOT EXISTS {indexName} ON {tableName} ({indexColumns});\"));\n        }\n\n        return new PhysicalizationPlan(\"SQLite\", policy, operations);\n    }\n\n    private static string Quote(string identifier)\n    {\n        if (!IdentifierRegex().IsMatch(identifier))\n            throw new InvalidOperationException($\"SQLite identifier '{identifier}' is not valid for physicalization.\");\n\n        return $\"\\\"{identifier}\\\"\";\n    }\n\n    [GeneratedRegex(\"^[A-Za-z_][A-Za-z0-9_]*$\", RegexOptions.Compiled)]\n    private static partial Regex IdentifierRegex();\n}\n","sourceCodeStart":36,"sourceCodeEnd":62,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Persistence.VNext.Sqlite/Physicalization/SqlitePhysicalizationPlanner.cs#L36-L62","documentation":"Quote validates every SQL identifier (table names, index names, columns) used in generated SQLite DDL against the regex ^[A-Za-z_][A-Za-z0-9_]*$. Identifiers containing dots, dashes, spaces, leading digits, or non-ASCII characters are rejected so the planner never emits unsafe or invalid quoted identifiers.","triggerScenarios":"Setting StoragePhysicalizationPolicy.PhysicalName to a value with invalid characters (e.g. workflow-instances, 9instances, dbo.WorkflowInstances) or declaring a schema storage unit/field/index whose name fails the regex, which then flows into tableName, fieldColumns, indexName, or indexColumns quoting.","commonSituations":"Copying logical names from other databases that allow dots or dashes; prefixing table names with digits; using hyphenated index names from configuration files.","solutions":["Rename the offending identifier to match ^[A-Za-z_][A-Za-z0-9_]*$ (letters, digits, underscores, not starting with a digit).","Set policy.PhysicalName to a sanitized, regex-compliant physical name distinct from the logical storage unit name.","Strip or replace invalid characters (e.g. dashes to underscores) before building the policy."],"exampleFix":"// before\npolicy.PhysicalName = \"workflow-instances\";\n// after\npolicy.PhysicalName = \"workflow_instances\";","handlingStrategy":"validation","validationCode":"static readonly Regex Ident = new(\"^[A-Za-z_][A-Za-z0-9_]*$\");\nif (!Ident.IsMatch(policy.PhysicalName ?? policy.StorageUnit))\n    throw new ArgumentException(\"Physical name must match ^[A-Za-z_][A-Za-z0-9_]*$.\");","typeGuard":null,"tryCatchPattern":"try { plan = planner.Plan(schema, policy); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"is not valid for physicalization\")) { policy.PhysicalName = Sanitize(name); /* retry */ }","preventionTips":["Sanitize logical names to underscores before creating policies.","Never pass dotted or hyphenated names as PhysicalName.","Add a schema-wide identifier lint test."],"tags":["sqlite","identifier","naming","physicalization"],"backgroundTag":"invalid-identifier-format","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}