migratediag

package
v0.86.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package migratediag provides redacted DSN summaries and uniform migration phase errors for hatchet-migrate and related migration binaries.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingEnv = errors.New("missing database environment variable")

ErrMissingEnv identifies a missing database DSN environment variable.

Functions

func MissingEnvError

func MissingEnvError(envVar, phase string) error

MissingEnvError returns a phase error for a missing DSN environment variable.

func PhaseError

func PhaseError(envVar, phase string, dsnSummary DSNSummary, stage string, err error) error

PhaseError wraps the original error with migration phase, DSN source, stage, and a redacted DSN summary.

Types

type DSNSummary

type DSNSummary string

DSNSummary is a redacted database connection string summary safe for logs.

func SummarizePostgresDSN

func SummarizePostgresDSN(raw string) DSNSummary

SummarizePostgresDSN returns a redacted, single-line summary of a postgres connection string suitable for logs and error messages.

The DSN is parsed via pgconn.ParseConfig, the same parser the pgx driver uses, so both URL form and libpq keyword form are handled. The summary emits only fields that are safe to log: host, port, database name, RuntimeParams keys, and a "tls" pseudo-key when TLS is enabled.

For example, postgres://user:pass@db:5432/app?sslmode=require&application_name=migrate becomes postgres://<redacted>@db:5432/app?keys=application_name,tls.

func SummarizeURLDSN

func SummarizeURLDSN(raw string) DSNSummary

SummarizeURLDSN returns a redacted, single-line summary of a URL-shaped connection string suitable for logs and error messages.

It preserves only fields that are safe to log: scheme, host, port, path, and query parameter keys. It should not be used for postgres DSNs, which can also arrive in libpq keyword form.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL