JuliusBrussee/caveman · error
postgres: set organization scope: %w
Error message
postgres: set organization scope: %w
What it means
Error "postgres: set organization scope: %w" thrown in JuliusBrussee/caveman.
Source
Thrown at shared/platform/postgresconfig/postgresconfig.go:775
}
return nil
}
// WithOrg runs fn inside a transaction whose tenant GUC is transaction-local.
// Empty scopes are rejected: tenant work must never degrade to an unscoped
// query when RLS is the hard boundary.
func WithOrg(ctx context.Context, pool *pgxpool.Pool, orgID string, fn func(pgx.Tx) error) error {
orgID = strings.TrimSpace(orgID)
if orgID == "" {
return errors.New("postgres: organization scope is required")
}
tx, err := pool.Begin(ctx)
if err != nil {
return err
}
defer func() { _ = tx.Rollback(ctx) }()
if _, err := tx.Exec(ctx, `SELECT set_config('app.current_organization_id', $1, true)`, orgID); err != nil {
return fmt.Errorf("postgres: set organization scope: %w", err)
}
if err := fn(tx); err != nil {
return err
}
return tx.Commit(ctx)
}
View on GitHub (pinned to 27d5a3981a)
Solutions
- Fix setting the organization scope on the connection.
When it happens
Trigger: Thrown at shared/platform/postgresconfig/postgresconfig.go:775 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/642c745a624f6d1d.
Report an issue: GitHub.