t8y2/dbx · error

custom type %s.%s is an array companion type

Error message

custom type %s.%s is an array companion type

What it means

The catalog row has typelem != 0, which identifies the type as the implicit array companion (_name) that PostgreSQL/Vastbase auto-creates for every base type, not a user-facing independent custom type. The library rejects it because describing an auto-generated array shell as a 'custom type' would be misleading; array handling belongs to column/array metadata instead.

Source

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

		return nil, fmt.Errorf("custom type %s.%s does not exist", schema, name)
	}
	var oid, typbasetype, typrelid, typelem, typcollation int64
	var typtype, typalign, typstorage string
	var typisdefined, typnotnull, typbyval bool
	var typdefaultbin, typdefault, inputFn, outputFn, receiveFn, sendFn, analyzeFn, comment, collname, relkind sql.NullString
	var typlen sql.NullInt64
	var typtypmod int64
	if err := rows.Scan(&oid, &typtype, &typisdefined, &typbasetype, &typnotnull, &typrelid, &typelem, &typcollation, &typdefaultbin, &typdefault, &typlen, &typbyval, &typalign, &typstorage, &typtypmod, &inputFn, &outputFn, &receiveFn, &sendFn, &analyzeFn, &comment, &relkind, &collname); err != nil {
		return nil, fmt.Errorf("failed to read type %s.%s: %w", schema, name, err)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if !typisdefined {
		return nil, fmt.Errorf("custom type %s.%s is not fully defined", schema, name)
	}
	if typelem != 0 {
		return nil, fmt.Errorf("custom type %s.%s is an array companion type", schema, name)
	}
	kind, ok := customTypeKindFromCode(typtype)
	if !ok {
		return nil, fmt.Errorf("custom type %s.%s is a pseudo type (typtype=%s)", schema, name, typtype)
	}
	if relkind.Valid && relkind.String != "" && relkind.String != "c" {
		return nil, fmt.Errorf("%s.%s is the auto-generated row type of a relation, not an independent custom type", schema, name)
	}

	properties := customTypeCommonProperties(inputFn, outputFn, receiveFn, sendFn, analyzeFn, typlen, typbyval, typalign, typstorage)
	properties.DomainConstraints = []customTypeDomainConstraint{}
	details := &customTypeDetails{
		Name:       name,
		Schema:     schema,
		Kind:       kind,
		Comment:    nullStringPtr(comment),
		Members:    []customTypeMember{},
		Properties: properties,

View on GitHub (pinned to c0390bff16)

Solutions

  1. Use the element type name instead of the array companion: query elem type via SELECT e.typname FROM pg_type t JOIN pg_type e ON e.oid=t.typelem WHERE t.typname='<arrayname>'
  2. Strip the leading underscore and/or resolve the base type before calling getTypeDetails
  3. Filter introspection queries with typelem = 0 (and typtype in ('e','c','d','r','m','b')) when enumerating candidate custom types
  4. If you actually need array info, use column/array metadata APIs rather than custom-type details

Example fix

// before
srv.getTypeDetails("public", "_widget")   // array companion
// after
srv.getTypeDetails("public", "widget")    // the element type
Defensive patterns

Strategy: type-guard

Validate before calling

if strings.HasPrefix(name, "_") { name = strings.TrimPrefix(name, "_") }

Type guard

func isArrayCompanionName(n string) bool { return strings.HasPrefix(n, "_") }

Try / catch

if err != nil && strings.Contains(err.Error(), "array companion") { name = strings.TrimPrefix(name, "_"); details, err = srv.getTypeDetails(schema, name) }

Prevention

When it happens

Trigger: Passing the internal array type name (e.g. '_widget', '_int4') or resolving a name that maps to the array companion OID rather than the element type; looking up a type obtained from typarray/typreceive contexts; introspection code that enumerated pg_type without filtering typelem != 0.

Common situations: Scripts that scrape pg_type without excluding array shells; hand-written migrations or ORM dumps that reference internal _-prefixed names; tooling that resolved an array column's type OID and then asked for its 'custom type' details.

Related errors


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