{"record":{"id":"30829dbfe671ffe6","repo":"micro/go-micro","slug":"errnotregistered","errorCode":"ErrNotRegistered","errorMessage":"table not registered","messagePattern":"table not registered","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"model/model.go","lineNumber":15,"sourceCode":"// Package model is an interface for structured data storage with schema awareness.\npackage model\n\nimport (\n\t\"context\"\n\t\"errors\"\n)\n\nvar (\n\t// ErrNotFound is returned when a record doesn't exist.\n\tErrNotFound = errors.New(\"not found\")\n\t// ErrDuplicateKey is returned when a record with the same key already exists.\n\tErrDuplicateKey = errors.New(\"duplicate key\")\n\t// ErrNotRegistered is returned when a table has not been registered.\n\tErrNotRegistered = errors.New(\"table not registered\")\n\t// DefaultModel is the default model.\n\tDefaultModel Model = NewModel()\n)\n\n// Model is a structured data storage interface.\ntype Model interface {\n\t// Init initializes the model.\n\tInit(...Option) error\n\t// Register registers a struct type as a table.\n\tRegister(v interface{}, opts ...RegisterOption) error\n\t// Create inserts a new record. Returns ErrDuplicateKey if key exists.\n\tCreate(ctx context.Context, v interface{}) error\n\t// Read retrieves a record by key into v. Returns ErrNotFound if missing.\n\tRead(ctx context.Context, key string, v interface{}) error\n\t// Update modifies an existing record. Returns ErrNotFound if missing.\n\tUpdate(ctx context.Context, v interface{}) error\n\t// Delete removes a record by key. v is a pointer to the struct type.\n\tDelete(ctx context.Context, key string, v interface{}) error","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/model/model.go#L1-L33","documentation":"model.ErrNotRegistered is returned when a table has not been registered with the model before use. schema lookups and List operations consult the registered table map and fail with this sentinel if the table name is unknown.","triggerScenarios":"Calling List or reading schema for a table name that was never passed through RegisterTable/registration; a typo'd table constant; using a fresh DefaultModel without registering tables.","commonSituations":"Refactoring renamed a table but missed the registration call; initialization order where queries run before registration; multiple Model instances where registration happened on a different instance.","solutions":["Register the table on the Model instance in use before any List/schema access.","Verify the exact table name string/constant matches the registered one.","Check initialization order so registration happens before first query.","Confirm you're using the same Model instance (DefaultModel vs a locally created one) that was registered."],"exampleFix":"// before\ntable, err := m.List(\"servcies\") // typo, unregistered\n// after\nm.RegisterTable(\"services\", schema)\ntable, err := m.List(\"services\")","handlingStrategy":"validation","validationCode":"func ensureTable(m model.Model, name string) error {\n    if _, err := m.List(name); errors.Is(err, model.ErrNotRegistered) {\n        return fmt.Errorf(\"table %q not registered: call RegisterTable first\", name)\n    }\n    return nil\n}","typeGuard":"func isNotRegistered(err error) bool { return errors.Is(err, model.ErrNotRegistered) }","tryCatchPattern":"rows, err := m.List(table)\nif errors.Is(err, model.ErrNotRegistered) {\n    return nil, fmt.Errorf(\"table %q missing registration; check init order\", table)\n}\nif err != nil { return nil, err }","preventionTips":["Register all tables in a single init/bootstrap function","Use shared constants for table names, never raw strings","Run registration before any query path in startup order","Verify you operate on the same Model instance that was registered"],"tags":["schema","data-access","initialization","sentinel-error"],"backgroundTag":"table-not-registered","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}