t8y2/dbx · error
failed to parse constraint %s referenced columns: %w
Error message
failed to parse constraint %s referenced columns: %w
What it means
Same as the constraint-columns parse failure but for the referenced (foreign-key) column list: parseVastbaseConstraintAttributeNumbers on confkey fails, wrapped as 'failed to parse constraint %s referenced columns'. Only foreign-key constraints carry confkey data, so this surfaces during FK introspection when that text is malformed.
Source
Thrown at agents/drivers/vastbase-go/vastbase_metadata.go:1589
refSchema, refTable sql.NullString
matchType, onUpdate, onDelete sql.NullString
deferrable, initiallyDeferred, valid, enabled bool
}
raw := []rawConstraint{}
for rows.Next() {
var item rawConstraint
var columnsRaw, refColumnsRaw sql.NullString
var validRaw, enabledRaw any
if err := rows.Scan(&item.name, &item.kind, &item.definition, &columnsRaw, &item.refSchema, &item.refTable, &refColumnsRaw, &item.matchType, &item.onUpdate, &item.onDelete, &item.deferrable, &item.initiallyDeferred, &validRaw, &enabledRaw); err != nil {
return nil, err
}
item.columnNumbers, err = parseVastbaseConstraintAttributeNumbers(columnsRaw.String)
if err != nil {
return nil, fmt.Errorf("failed to parse constraint %s columns: %w", item.name, err)
}
item.refColumnNumbers, err = parseVastbaseConstraintAttributeNumbers(refColumnsRaw.String)
if err != nil {
return nil, fmt.Errorf("failed to parse constraint %s referenced columns: %w", item.name, err)
}
item.valid = parseVastbaseConstraintValid(validRaw)
item.enabled = parseVastbaseConstraintEnabled(enabledRaw)
raw = append(raw, item)
}
if err := rows.Err(); err != nil {
return nil, err
}
attributes, err := s.relationAttributesByNumber(catalog, prefix, effective, table)
if err != nil {
return nil, err
}
refAttributes := map[string]map[int]string{}
result := make([]constraintInfo, 0, len(raw))
for _, item := range raw {
constraint := constraintInfo{
Name: item.name, ConstraintType: vastbaseConstraintTypeName(item.kind), Definition: item.definition,View on GitHub (pinned to c0390bff16)
Solutions
- Inspect the named constraint's confkey value in the catalog to see the malformed text.
- Verify driver and server versions are compatible; update the driver for catalog format changes.
- Re-check/recreate the constraint if catalog data is genuinely corrupted.
- If empty confkey is legitimate for your server, patch/upgrade the driver to tolerate it.
Defensive patterns
Strategy: validation
Validate before calling
var confkey string
err := db.QueryRow(`SELECT confkey::text FROM pg_constraint WHERE conname=$1 AND contype='f'`, cname).Scan(&confkey)
if err == nil {
for _, tok := range strings.FieldsFunc(confkey, func(r rune) bool { return r == ',' || r == ' ' || r == '\t' }) {
if _, e := strconv.Atoi(tok); e != nil {
return fmt.Errorf("malformed confkey %q for FK %s", confkey, cname)
}
}
} Try / catch
fks, err := srv.ListForeignKeys(schema, table)
if err != nil && strings.Contains(err.Error(), "referenced columns") {
// inspect confkey for the constraint named in the error
return err
} Prevention
- Validate FK definitions after migrations that touch foreign keys.
- Keep driver updated for catalog format changes.
- Recreate constraints whose catalog values look corrupt.
When it happens
Trigger: Introspecting foreign key constraints when a constraint row's confkey text cannot be parsed into attribute numbers — empty string, NULL-ish rendering, or unexpected separators/characters.
Common situations: FK constraints against unusual server builds; driver/server catalog format mismatch; partially corrupted catalog metadata after failed migrations.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse constraint %s columns: %w
- invalid attribute number %q
- %s.%s is the auto-generated row type of a relation, not an i
- failed to read enum values: %w
- failed to read composite fields: %w
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/fd42708fd5b01cfd.
Report an issue: GitHub.