t8y2/dbx · error
failed to read enum values: %w
Error message
failed to read enum values: %w
What it means
This error wraps a failure of the metadata query that reads enum member values (enumsortorder/enumlabel) from the catalog for an enum custom type. It is returned by customTypeEnumMembers when the query itself fails to execute (connection, permissions, SQL syntax against the catalog). It is not a 'type not found' error — the enum row was already located; only reading its values failed.
Source
Thrown at agents/drivers/vastbase-go/vastbase_metadata.go:726
properties.AnalyzeFunction = nullStringPtr(analyzeFn)
if typlen.Valid && typlen.Int64 > 0 {
value := int32(typlen.Int64)
properties.Internallength = &value
}
properties.PassedByValue = &typbyval
if typalign != "" {
properties.Alignment = &typalign
}
if typstorage != "" {
properties.Storage = &typstorage
}
return properties
}
func (s *server) customTypeEnumMembers(sqlTemplate string, oid int64) ([]customTypeMember, error) {
rows, err := s.metadataQuery(fmt.Sprintf(sqlTemplate, oid))
if err != nil {
return nil, fmt.Errorf("failed to read enum values: %w", err)
}
defer rows.Close()
var members []customTypeMember
index := 0
for rows.Next() {
var label string
var sortOrder float64
if err := rows.Scan(&label, &sortOrder); err != nil {
return nil, err
}
// enumsortorder is float4; ALTER TYPE ... ADD VALUE BEFORE/AFTER can
// yield fractional values. Use the ORDER BY position for a unique key.
index++
members = append(members, customTypeMember{Ordinal: int32(index), EnumValue: &label})
}
return members, rows.Err()
}
View on GitHub (pinned to c0390bff16)
Solutions
- Check DB connectivity and re-run the introspection; inspect the wrapped cause (%w) for the root error.
- Grant the connecting user SELECT on the catalog enum views (pg_enum/sys_catalog equivalents).
- Confirm s.mode.postgresCatalog matches the actual server catalog flavor so the correct catalog queries are used.
- Retry after transient network errors; escalate if the wrapped error is a SQL syntax/permission error.
Example fix
// before
// introspecting with a user lacking catalog access
srv, _ := New(serverCfg) // user 'app_ro' without catalog SELECT
_, err := srv.CustomTypeDetails("public", "color_enum")
// failed to read enum values: permission denied ...
// after
// grant catalog read access to the introspection role
// GRANT SELECT ON pg_enum TO app_ro; Defensive patterns
Strategy: retry
Validate before calling
// verify connectivity and privileges up front
if err := db.Ping(); err != nil { return err }
var n int
if err := db.QueryRow("SELECT COUNT(*) FROM pg_enum LIMIT 1").Scan(&n); err != nil {
return fmt.Errorf("no catalog enum access: %w", err)
} Try / catch
details, err := srv.CustomTypeDetails(schema, name)
if err != nil {
var wrapped error
if errors.As(err, &wrapped) && isTransient(wrapped) {
// retry with backoff
}
return fmt.Errorf("enum introspection failed: %w", err)
} Prevention
- Grant catalog SELECT privileges to the introspection role.
- Keep connections healthy; use pool health checks before long introspection runs.
- Match the driver catalog mode (postgresCatalog) to the actual server.
When it happens
Trigger: Calling custom type details for an enum type when the underlying metadataQuery for enum members errors: connection dropped mid-session, insufficient privileges on sys_catalog/pg_catalog enum views, or catalog query incompatibility (e.g. postgresCatalog mode flag mismatch with actual server catalog).
Common situations: Network interruption while introspecting an enum; restricted monitoring account lacking catalog read privileges; driver mode configured for pg_catalog on a server that only exposes sys_catalog (or vice versa).
Related errors
- failed to read composite fields: %w
- routine source is not supported for %s connections
- failed to read enum values: %w
- list custom types in schema %q: %w
- failed to locate custom type %s.%s: %w
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/70dd0941d8db29c8.
Report an issue: GitHub.