{"record":{"id":"3628bae0a4c23689","repo":"bytebase/bytebase","slug":"unknown-object-kind-d","errorCode":null,"errorMessage":"unknown object kind %d","messagePattern":"unknown object kind (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/schema/pg/walk_through_loader.go","lineNumber":692,"sourceCode":"\t\t\treturn cat.AddConstraint(obj.schema, obj.parentName, catalog.ConstraintDef{\n\t\t\t\tName:    obj.idxMeta.Name,\n\t\t\t\tType:    catalog.ConstraintPK,\n\t\t\t\tColumns: wtUnquoteColumns(obj.idxMeta.Expressions),\n\t\t\t})\n\t\t}\n\t\tif obj.idxMeta.IsConstraint && obj.idxMeta.Unique {\n\t\t\treturn cat.AddConstraint(obj.schema, obj.parentName, catalog.ConstraintDef{\n\t\t\t\tName:    obj.idxMeta.Name,\n\t\t\t\tType:    catalog.ConstraintUnique,\n\t\t\t\tColumns: wtUnquoteColumns(obj.idxMeta.Expressions),\n\t\t\t})\n\t\t}\n\t\treturn wtInstallIndex(cat, obj)\n\n\tcase kindWTConstraint:\n\t\treturn wtInstallConstraint(cat, obj)\n\t}\n\treturn errors.Errorf(\"unknown object kind %d\", obj.kind)\n}\n\nfunc wtInstallSequence(cat *catalog.Catalog, obj *wtObjectEntry) error {\n\tseq := obj.seqMeta\n\tif seq == nil {\n\t\treturn errors.New(\"sequence has no metadata\")\n\t}\n\n\tstmt := &ast.CreateSeqStmt{\n\t\tSequence: &ast.RangeVar{\n\t\t\tSchemaname:     obj.schema,\n\t\t\tRelname:        seq.Name,\n\t\t\tRelpersistence: 'p',\n\t\t},\n\t}\n\n\tvar opts []ast.Node\n\tif seq.Increment != \"\" && seq.Increment != \"0\" {","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/schema/pg/walk_through_loader.go#L674-L710","documentation":"wtInstallReal dispatches each collected object by its kind (table, view, sequence, index, constraint, composite type, ...). If obj.kind holds a value the switch does not handle, it returns `unknown object kind %d`. This is a defensive invariant check: the library throws it when the walkthrough loader collects an object kind that installation has no handler for.","triggerScenarios":"A wtObjectEntry whose kind field was set to a value outside the kinds handled by the switch in wtInstallReal (e.g. a newly added kindWT* constant collected by wtCollectObjects but not given a wtInstall* branch).","commonSituations":"A developer added a new object kind to wtCollectObjects but forgot to add the corresponding case in wtInstallReal; corrupted/inconsistent in-memory object entries built during collection.","solutions":["Add a case for the new kind in wtInstallReal's switch delegating to a wtInstall* handler","Check wtCollectObjects for code that constructs wtObjectEntry with an uninitialized or unhandled kind","Log obj.name alongside the kind to identify which object triggers the gap"],"exampleFix":"// before\nswitch obj.kind {\ncase kindWTConstraint:\n\treturn wtInstallConstraint(cat, obj)\n}\nreturn errors.Errorf(\"unknown object kind %d\", obj.kind)\n// after\nswitch obj.kind {\ncase kindWTConstraint:\n\treturn wtInstallConstraint(cat, obj)\ncase kindWTFunction:\n\treturn wtInstallFunction(cat, obj)\n}\nreturn errors.Errorf(\"unknown object kind %d\", obj.kind)","handlingStrategy":"validation","validationCode":"switch obj.kind {\ncase kindWTTable, kindWTView, kindWTSequence, kindWTIndex, kindWTConstraint, kindWTComposite:\ndefault:\n\treturn fmt.Errorf(\"object %s: unhandled kind %d\", obj.name, obj.kind)\n}","typeGuard":"func knownKind(k wtKind) bool {\n\tswitch k {\n\tcase kindWTTable, kindWTView, kindWTSequence, kindWTIndex, kindWTConstraint, kindWTComposite:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := wtInstallReal(cat, obj); err != nil {\n\tif strings.Contains(err.Error(), \"unknown object kind\") {\n\t\tlog.Warnf(\"unsupported object %s: %v\", obj.name, err)\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Whenever you add a kindWT* constant, immediately add the install case in the same change","Use an exhaustive-switch lint or make the switch return on default in tests","Cover every kind in a table-driven install test"],"tags":["postgres","schema","dispatch","internal"],"backgroundTag":"invalid-enum-value","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}