JuliusBrussee/caveman · error

postgres: inspect runtime identity: %w

Error message

postgres: inspect runtime identity: %w

What it means

Error "postgres: inspect runtime identity: %w" thrown in JuliusBrussee/caveman.

Source

Thrown at shared/platform/postgresconfig/postgresconfig.go:166

		       r.rolbypassrls,
		       pg_has_role(current_user, $1, 'MEMBER'),
		       EXISTS (
		         SELECT 1
		         FROM pg_class c
		         JOIN pg_namespace n ON n.oid=c.relnamespace
		         JOIN information_schema.columns col
		           ON col.table_schema=n.nspname
		          AND col.table_name=c.relname
		          AND col.column_name='organization_id'
		         WHERE n.nspname='public'
		           AND c.relkind IN ('r','p')
		           AND pg_get_userbyid(c.relowner)=current_user
		       )
		FROM pg_roles r
		WHERE r.rolname=current_user
	`, expectedRole).Scan(&currentUser, &sessionUser, &superuser, &bypassRLS, &member, &ownsTenantTable)
	if err != nil {
		return fmt.Errorf("postgres: inspect runtime identity: %w", err)
	}
	return validateRuntimeIdentity(currentUser, sessionUser, expectedRole, superuser, bypassRLS, member, ownsTenantTable)
}

func validateRuntimeIdentity(currentUser, sessionUser, expectedRole string, superuser, bypassRLS, member, ownsTenantTable bool) error {
	// A safe SET ROLE is not a safe login: session_user may execute SET ROLE
	// NONE later and recover its original privileges. Runtime pools therefore
	// require the authenticated identity and effective identity to be identical.
	if currentUser != sessionUser {
		return fmt.Errorf("postgres: runtime current_user %q differs from session_user %q", currentUser, sessionUser)
	}
	if superuser || bypassRLS || ownsTenantTable {
		return fmt.Errorf("postgres: unsafe runtime identity %q (session_user=%q superuser=%t bypassrls=%t owns_tenant_table=%t)", currentUser, sessionUser, superuser, bypassRLS, ownsTenantTable)
	}
	if !member {
		return fmt.Errorf("postgres: runtime identity %q is not a member of %q", currentUser, expectedRole)
	}
	return nil

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Fix the runtime identity inspection error and retry.

When it happens

Trigger: Thrown at shared/platform/postgresconfig/postgresconfig.go:166 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/5929b4a554a180fb. Report an issue: GitHub.