t8y2/dbx · error

list custom types in schema %q: %w

Error message

list custom types in schema %q: %w

What it means

When listing all objects in a schema, if the custom-type enumeration (listCustomTypes) fails, the driver returns this wrapped error instead of silently omitting types. The comment in the source explains the intent: a type-catalog failure must be distinguishable from an actually empty type group, so the caller sees a real fault.

Source

Thrown at agents/drivers/vastbase-go/vastbase_metadata.go:1071

		rows, queryErr := s.metadataQuery(query)
		if queryErr == nil {
			for rows.Next() {
				var name, kind string
				var comment sql.NullString
				if rows.Scan(&name, &kind, &comment) == nil {
					result = append(result, objectInfo{Name: name, ObjectType: kind, Schema: effective, Comment: nullStringPtr(comment)})
				}
			}
			_ = rows.Close()
		}
	}
	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

  1. Inspect the wrapped cause (%w) to find whether it's permissions, connectivity, or a query error.
  2. Grant catalog SELECT privileges to the introspection user so custom type enumeration succeeds.
  3. Retry the listing if the cause is transient (network).
  4. If you genuinely need to skip types on failure, wrap/handle at a layer above rather than modifying driver behavior.
  5. Verify the catalog mode setting matches the server.
Defensive patterns

Strategy: try-catch

Validate before calling

if err := db.Ping(); err != nil { return err }
if _, err := db.Query("SELECT 1 FROM pg_type LIMIT 1"); err != nil {
    return fmt.Errorf("catalog type access missing: %w", err)
}

Try / catch

objects, err := srv.ListSchemaObjects(schema, constraints)
if err != nil {
    var typeErr error
    if errors.As(err, &typeErr) && strings.Contains(err.Error(), "list custom types") {
        log.Printf("type group incomplete for %s: %v", schema, err)
    }
    return err // do not treat as empty schema
}

Prevention

When it happens

Trigger: Calling the list-schema-objects API with constraints that allow types (constraintsAllowTypes true) while listCustomTypes fails — e.g. catalog permission errors, connection drops, or catalog query incompatibilities during custom type enumeration.

Common situations: Schema-wide introspection with a restricted role; unstable connections during large schema scans; wrong catalog mode for the server version.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/62298c4e920443a7. Report an issue: GitHub.