t8y2/dbx · error
list custom types in schema %q: %w
Error message
list custom types in schema %q: %w
What it means
This error wraps a failure from s.listCustomTypes while the server is enumerating all objects in a schema. Custom types (enums, domains, composite types) are fetched as one group of the schema object listing; if that catalog query fails, the whole listing aborts with this message instead of silently returning a list missing the type group. The wrapper preserves the underlying driver error via %w.
Source
Thrown at agents/drivers/kingbase-go/kingbase_metadata.go:1156
}
}
_ = rows.Close()
}
}
if constraintsAllowTriggers(constraints) {
triggers, triggerErr := s.listTriggerObjects(effective)
if triggerErr != nil {
return nil, fmt.Errorf("list triggers in schema %q: %w", effective, triggerErr)
}
result = append(result, triggers...)
}
if constraintsAllowTypes(constraints) {
types, typesErr := s.listCustomTypes(effective)
if typesErr != nil {
// A type catalog failure is a real fault: surfacing it lets the user
// distinguish an incomplete “all objects” view from an actually
// empty schema, instead of silently dropping the type group.
return nil, fmt.Errorf("list custom types in schema %q: %w", effective, typesErr)
}
result = append(result, types...)
}
filtered := result[:0]
for _, item := range result {
if constraintsMatch(constraints, item.Name, item.ObjectType) {
filtered = append(filtered, item)
}
}
sort.SliceStable(filtered, func(i, j int) bool {
if objectOrder(filtered[i].ObjectType) != objectOrder(filtered[j].ObjectType) {
return objectOrder(filtered[i].ObjectType) < objectOrder(filtered[j].ObjectType)
}
return filtered[i].Name < filtered[j].Name
})
return pageObjects(filtered, constraints), nil
}
View on GitHub (pinned to c0390bff16)
Solutions
- Check the wrapped (Unwrap'ed) driver error to find the real cause — query failure, permission, or missing catalog view
- Verify the compatibility mode (mysqlCompat / postgresCatalog) matches the actual Kingbase server version
- Grant the connecting role SELECT permission on the system catalog (sys_catalog / pg_catalog) tables
- Retry the listing if the wrapped error indicates a transient connection issue
Example fix
// before: assuming empty schema on listing error
objects, err := driver.ListObjects(schema, nil)
if err != nil { return empty }
// after: surface the wrapped cause
objects, err := driver.ListObjects(schema, nil)
if err != nil {
var dbErr *gokb.Error
if errors.As(err, &dbErr) { log.Printf("catalog error code=%s", dbErr.Code) }
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go: probe catalog access before listing objects
var probe int
err := db.QueryRow(`SELECT 1 FROM sys_catalog.sys_type LIMIT 1`).Scan(&probe)
if err != nil {
return fmt.Errorf("type catalog not readable (check permissions/version/compat mode): %w", err)
} Try / catch
objects, err := srv.ListObjects(schema, constraints)
if err != nil {
var msg string
if errors.As(err, new(*gokb.Error)) {
msg = "catalog error - check version/permissions"
} else if strings.Contains(err.Error(), "list custom types in schema") {
msg = "type listing failed; schema view would be incomplete"
}
return fmt.Errorf("listing schema %s objects: %w (%s)", schema, err, msg)
} Prevention
- Verify the Kingbase server version and set mysqlCompat/postgresCatalog compat mode to match before listing objects
- Grant the application role SELECT on sys_catalog/pg_catalog tables used for metadata
- Smoke-test each metadata group (tables, routines, triggers, types) against staging environments on upgrade
- Do not swallow listing errors and treat the result as complete — an incomplete view hides types
When it happens
Trigger: Calling the schema object listing API (e.g. listObjects/describe schema) with constraints that allow types (constraintsAllowTypes) on a Kingbase database whose type catalog query fails — e.g. missing sys_catalog/pg_catalog type views in a compatibility mode, permission denial on catalog tables, or a driver/connection error during the metadata query.
Common situations: Connecting to an older or non-standard Kingbase version where the catalog layout differs from the assumed compat mode; a role lacking SELECT on catalog objects; transient connection loss during metadata enumeration; mysqlCompat/postgresCatalog mode misconfigured so the wrong catalog schema is queried.
Related errors
- invalid attribute number %q
- custom type %s.%s is a pseudo type (typtype=%s)
- %s.%s is the auto-generated row type of a relation, not an i
- failed to parse index %s columns: %w
- failed to parse foreign key %s columns: %w
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/baf242cd6567ba78.
Report an issue: GitHub.