t8y2/dbx · error

list triggers in schema %q: %w

Error message

list triggers in schema %q: %w

What it means

listObjects (the 'all objects in schema' metadata listing) aggregates tables, routines, triggers, and types. When triggers are allowed by the request constraints, it calls listTriggerObjects; any failure is wrapped as 'list triggers in schema %q', so the whole schema listing fails rather than silently returning a result missing the trigger group — surfacing the fault lets callers distinguish an incomplete view from an actually empty schema.

Source

Thrown at agents/drivers/kingbase-go/kingbase_metadata.go:1146

LEFT JOIN %s.%s_description d ON d.objoid = p.oid AND d.objsubid = 0
WHERE n.nspname = %s ORDER BY p.proname`, catalog, function, catalog, function, catalog, function, quoteLiteral(effective))
		}
		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 constraintsAllowTriggers(constraints) {
		triggers, triggerErr := s.listTriggerObjects(effective)
		if triggerErr != nil {
			return nil, fmt.Errorf("list triggers in schema %q: %w", effective, triggerErr)
		}
		result = append(result, triggers...)
	}
	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)
		}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Read the wrapped inner error (%w) to identify the actual trigger-query failure
  2. Grant the connecting role SELECT on the trigger catalogs (pg_trigger/sys_trigger, pg_proc/sys_proc)
  3. Verify the driver's catalog mode (postgresCatalog vs MySQL-compat) matches the server
  4. Retry the listing if the inner error is transient; or request the listing with triggers excluded if you don't need them

Example fix

// before
objects, err := server.ListObjects("public", metadataListConstraints{})
// after — skip triggers if their introspection isn't needed
constraints := metadataListConstraints{ /* trigger-disallowing preset */ }
objects, err := server.ListObjects("public", constraints)
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: confirm the role can read trigger catalogs before the wide listing
if !roleCanSelect("pg_trigger", "pg_proc") && !roleCanSelect("sys_trigger", "sys_proc") { grantTriggerCatalogAccess() }

Type guard

func listingFailedWithTriggerError(err error) bool {
  return err != nil && strings.Contains(err.Error(), "list triggers in schema")
}

Try / catch

objects, err := server.ListObjects(schema, constraints)
if err != nil {
  if listingFailedWithTriggerError(err) && isTransient(err) {
    return retryWithBackoff()
  }
  if listingFailedWithTriggerError(err) {
    return listObjectsWithoutTriggers(schema) // degraded listing
  }
  return err
}

Prevention

When it happens

Trigger: Calling the list-objects/list-schema-objects metadata API with triggers included (constraintsAllowTriggers true) on a schema where the trigger catalog query fails — missing privileges on trigger-related catalogs, SQL incompatibility with the Kingbase mode, or a connection error.

Common situations: Limited-privilege role connecting to the database; Kingbase instance whose trigger catalog layout (pg_trigger/sys_trigger with pg_proc joins) differs from what the driver expects; transient network failure during a broad introspection sweep.

Related errors


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