t8y2/dbx · error
failed to read composite fields: %w
Error message
failed to read composite fields: %w
What it means
This error wraps a failure of the catalog query that reads composite type fields (attribute names, types, ordinals) for a composite custom type, returned by customTypeCompositeMembers when metadataQuery fails. Like the enum variant, the composite type row was found; only reading its member fields failed.
Source
Thrown at agents/drivers/vastbase-go/vastbase_metadata.go:748
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()
}
func (s *server) customTypeCompositeMembers(sqlTemplate string, typrelid int64) ([]customTypeMember, error) {
rows, err := s.metadataQuery(fmt.Sprintf(sqlTemplate, typrelid, typrelid))
if err != nil {
return nil, fmt.Errorf("failed to read composite fields: %w", err)
}
defer rows.Close()
var members []customTypeMember
for rows.Next() {
var member customTypeMember
var hasDefault bool
var comment sql.NullString
if err := rows.Scan(&member.Name, &member.DataType, &member.Ordinal, &member.Nullable, &hasDefault, &member.Default, &comment); err != nil {
return nil, err
}
if !hasDefault {
member.Default = nil
}
member.Comment = nullStringPtr(comment)
members = append(members, member)
}
return members, rows.Err()
}View on GitHub (pinned to c0390bff16)
Solutions
- Re-check connectivity and retry; inspect the wrapped cause for the underlying DB error.
- Grant the introspection role SELECT on pg_attribute/pg_type (or sys_catalog equivalents).
- Ensure the driver's catalog mode (postgresCatalog flag) matches the target server.
- If the wrapped error is structural (unknown column), update the driver or adjust catalog query templates.
Defensive patterns
Strategy: retry
Validate before calling
if err := db.Ping(); err != nil { return err }
var n int
if err := db.QueryRow("SELECT COUNT(*) FROM pg_attribute LIMIT 1").Scan(&n); err != nil {
return fmt.Errorf("no catalog attribute access: %w", err)
} Try / catch
details, err := srv.CustomTypeDetails(schema, name)
if err != nil && strings.Contains(err.Error(), "failed to read composite fields") {
if isTransient(errors.Unwrap(err)) { /* retry with backoff */ }
} Prevention
- Ensure the introspection role can read pg_attribute/pg_type.
- Retry transient network failures with backoff.
- Verify driver/server version compatibility before large introspection jobs.
When it happens
Trigger: Requesting details of a composite type when the composite-members metadata query errors: connection loss, missing catalog privileges on pg_attribute/pg_type joins, or catalog query templates mismatched to the server (sys_catalog vs pg_catalog mode).
Common situations: Introspecting composite types with a limited-privilege role; transient network failures; running against a Vastbase build whose catalog layout differs from the assumed template.
Related errors
- failed to read enum values: %w
- routine source is not supported for %s connections
- list custom types in schema %q: %w
- failed to locate custom type %s.%s: %w
- failed to read type %s.%s: %w
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/e5baafeadfddd7a6.
Report an issue: GitHub.