micro/go-micro · error
ErrNotRegistered
ErrNotRegistered
Error message
table not registered
What it means
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.
Source
Thrown at model/model.go:15
// Package model is an interface for structured data storage with schema awareness.
package model
import (
"context"
"errors"
)
var (
// ErrNotFound is returned when a record doesn't exist.
ErrNotFound = errors.New("not found")
// ErrDuplicateKey is returned when a record with the same key already exists.
ErrDuplicateKey = errors.New("duplicate key")
// ErrNotRegistered is returned when a table has not been registered.
ErrNotRegistered = errors.New("table not registered")
// DefaultModel is the default model.
DefaultModel Model = NewModel()
)
// Model is a structured data storage interface.
type Model interface {
// Init initializes the model.
Init(...Option) error
// Register registers a struct type as a table.
Register(v interface{}, opts ...RegisterOption) error
// Create inserts a new record. Returns ErrDuplicateKey if key exists.
Create(ctx context.Context, v interface{}) error
// Read retrieves a record by key into v. Returns ErrNotFound if missing.
Read(ctx context.Context, key string, v interface{}) error
// Update modifies an existing record. Returns ErrNotFound if missing.
Update(ctx context.Context, v interface{}) error
// Delete removes a record by key. v is a pointer to the struct type.
Delete(ctx context.Context, key string, v interface{}) errorView on GitHub (pinned to 24529f1404)
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.
Example fix
// before
table, err := m.List("servcies") // typo, unregistered
// after
m.RegisterTable("services", schema)
table, err := m.List("services") Defensive patterns
Strategy: validation
Validate before calling
func ensureTable(m model.Model, name string) error {
if _, err := m.List(name); errors.Is(err, model.ErrNotRegistered) {
return fmt.Errorf("table %q not registered: call RegisterTable first", name)
}
return nil
} Type guard
func isNotRegistered(err error) bool { return errors.Is(err, model.ErrNotRegistered) } Try / catch
rows, err := m.List(table)
if errors.Is(err, model.ErrNotRegistered) {
return nil, fmt.Errorf("table %q missing registration; check init order", table)
}
if err != nil { return nil, err } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/30829dbfe671ffe6.
Report an issue: GitHub.