JuliusBrussee/caveman · error
postgres: read %s: %w
Error message
postgres: read %s: %w
What it means
Error "postgres: read %s: %w" thrown in JuliusBrussee/caveman.
Source
Thrown at shared/platform/postgresconfig/postgresconfig.go:97
func caPEMFromEnvironment() (string, error) {
filePath := strings.TrimSpace(os.Getenv(caFileEnvironment))
direct := strings.TrimSpace(os.Getenv(caEnvironment))
if filePath != "" && direct != "" {
return "", fmt.Errorf("postgres: set only %s or %s, not both", caFileEnvironment, caEnvironment)
}
if filePath == "" {
return direct, nil
}
info, err := os.Stat(filePath)
if err != nil {
return "", fmt.Errorf("postgres: %s: %w", caFileEnvironment, err)
}
if !info.Mode().IsRegular() {
return "", fmt.Errorf("postgres: %s must point to a regular file", caFileEnvironment)
}
contents, err := os.ReadFile(filePath)
if err != nil {
return "", fmt.Errorf("postgres: read %s: %w", caFileEnvironment, err)
}
return strings.TrimSpace(string(contents)), nil
}
// NewPool constructs a pool from the hardened configuration.
func NewPool(ctx context.Context, databaseURL string) (*pgxpool.Pool, error) {
config, err := ParsePoolConfig(databaseURL)
if err != nil {
return nil, err
}
return pgxpool.NewWithConfig(ctx, config)
}
// NewRuntimePool constructs a pool and proves the connected login is a
// least-privilege member of expectedRole. Runtime services must never connect
// as a superuser, BYPASSRLS role, or owner of a tenant table; this remains true
// for local, on-prem, staging, and production deployments alike.
func NewRuntimePool(ctx context.Context, databaseURL, expectedRole string) (*pgxpool.Pool, error) {View on GitHub (pinned to 27d5a3981a)
Solutions
- Fix reading the named file (path/permissions).
When it happens
Trigger: Thrown at shared/platform/postgresconfig/postgresconfig.go:97 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/8304ddfb2698389d.
Report an issue: GitHub.