{"record":{"id":"3a29d7dafa99aa7f","repo":"vitessio/vitess","slug":"invalid-table-name-s","errorCode":null,"errorMessage":"invalid table name: %s","messagePattern":"invalid table name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/controller_plan.go","lineNumber":186,"sourceCode":"\tif ins == nil {\n\t\treturn nil, errors.New(\"BUG: invalid nil INSERT statement found when building VReplication plan\")\n\t}\n\ttableName, err := ins.Table.TableName()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif tableName.Qualifier.String() != sidecar.GetName() && tableName.Qualifier.String() != sidecar.DefaultName {\n\t\treturn nil, fmt.Errorf(\"invalid database name: %s\", tableName.Qualifier.String())\n\t}\n\tswitch tableName.Name.String() {\n\tcase reshardingJournalTableName:\n\t\treturn &controllerPlan{\n\t\t\topcode: reshardingJournalQuery,\n\t\t}, nil\n\tcase vreplicationTableName:\n\t\t// no-op\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid table name: %s\", tableName.Name.String())\n\t}\n\tif ins.Action != sqlparser.InsertAct {\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %v\", sqlparser.String(ins))\n\t}\n\tif ins.Ignore {\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %v\", sqlparser.String(ins))\n\t}\n\tif ins.Partitions != nil {\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %v\", sqlparser.String(ins))\n\t}\n\tif ins.OnDup != nil {\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %v\", sqlparser.String(ins))\n\t}\n\trows, ok := ins.Rows.(sqlparser.Values)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %v\", sqlparser.String(ins))\n\t}\n\tidPos := 0","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/controller_plan.go#L168-L204","documentation":"Returned by vreplication controller plan building when a table name parsed from a routing rule or query construct is not a valid identifier.","triggerScenarios":"An INSERT statement against a sidecar table other than vreplication or resharding_journal — e.g. `insert into _vt.copy_state ...` sent through the vreplication engine's plan builder.","commonSituations":"Operators trying to hand-edit internal bookkeeping tables (copy_state, lag, etc.) via VExec; tooling that assumed all sidecar tables are writable through this path; scripts written for direct-MySQL use repointed at the vreplication engine.","solutions":["Restrict engine-driven INSERTs to _vt.vreplication (and _vt.resharding_journal).","For internal tables like _vt.copy_state, execute the statement directly on the tablet's MySQL as the vt_dba user.","Use the documented workflow commands (vtctldclient) instead of mutating internal tables.","If a new sidecar table needs engine support, add a case in buildInsertPlan upstream."],"exampleFix":"// before\ninsert into _vt.copy_state(vid, uid) values (1, 2)\n// after — run on tablet MySQL directly, or use a supported table:\ninsert into _vt.vreplication(id, workflow) values (1, 'w')","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"vreplication\": true, \"resharding_journal\": true}\ntable := tableNameFromInsert(stmt)\nif !allowed[table] {\n    return fmt.Errorf(\"table %s is not engine-writable; use tablet MySQL directly\", table)\n}","typeGuard":null,"tryCatchPattern":"plan, err := buildInsertPlan(ins, sidecar)\nif err != nil && strings.Contains(err.Error(), \"invalid table name\") {\n    return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, \"only _vt.vreplication and _vt.resharding_journal accept engine INSERTs\")\n}","preventionTips":["Treat _vt.copy_state and other internal tables as read-only via the engine.","Manage internal tables only via vtctldclient or direct MySQL as an operator.","Document which sidecar tables are engine-writable for your team's tooling."],"tags":["sql","vreplication","validation"],"backgroundTag":"invalid-table-name","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}