diagnostics

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyItem

func EmptyItem() contract.DiagnosticItem

EmptyItem returns the zero DiagnosticItem from the diagnostics package so production callers do not construct DiagnosticItem literals directly.

func ItemFromError

func ItemFromError(err error) (contract.DiagnosticItem, bool)

ItemFromError extracts a redacted DiagnosticItem from any diagnostic-bearing error.

func NewItem

func NewItem(
	spec ItemSpec,
	options ...ItemOption,
) contract.DiagnosticItem

NewItem builds the canonical redacted DiagnosticItem.

func Redact

func Redact(text string) string

Redact removes common credential shapes from diagnostic text before the text is persisted or exposed to operators.

func RedactAndBound

func RedactAndBound(text string, maxBytes int) string

RedactAndBound redacts diagnostic text and caps it to a deterministic byte budget. Callers should use this before storing crash evidence.

func RedactEvidence

func RedactEvidence(evidence map[string]any) map[string]any

RedactEvidence recursively redacts evidence values without mutating the input map.

func RedactExact

func RedactExact(text string) string

RedactExact removes canonical and registered secrets without additive heuristics.

func RedactExactBinary

func RedactExactBinary(text string) string

RedactExactBinary removes literal and reversibly encoded registered secrets from text.

func RedactExactBinaryJSON

func RedactExactBinaryJSON(raw json.RawMessage) (json.RawMessage, error)

RedactExactBinaryJSON removes literal and reversibly encoded registered secrets from structured JSON.

func RedactExactBytes

func RedactExactBytes(value []byte) []byte

RedactExactBytes removes registered secrets from opaque bytes before they are encoded.

func RedactExactJSON

func RedactExactJSON(raw json.RawMessage) (json.RawMessage, error)

RedactExactJSON removes canonical and registered secrets from structured JSON.

func RedactItem

RedactItem reapplies the diagnostics redaction boundary to an existing item.

func RedactJSON

func RedactJSON(raw []byte) ([]byte, error)

RedactJSON recursively redacts secret-shaped values inside a JSON document.

func RedactValue

func RedactValue(value any) any

RedactValue recursively redacts diagnostic evidence values.

func RegisterDynamicSecret

func RegisterDynamicSecret(value string) func()

RegisterDynamicSecret registers one runtime-resolved secret for diagnostic redaction.

func RegisterRequiredSecret

func RegisterRequiredSecret(value string) func()

RegisterRequiredSecret registers one caller-classified secret without a length heuristic.

Types

type ItemOption

type ItemOption func(*itemOptions)

ItemOption customizes a DiagnosticItem built by NewItem.

func WithDocURL

func WithDocURL(url string) ItemOption

WithDocURL records the documentation URL for a diagnostic.

func WithEvidence

func WithEvidence(evidence map[string]any) ItemOption

WithEvidence attaches structured diagnostic evidence after recursive redaction.

func WithSuggestedCommand

func WithSuggestedCommand(command string) ItemOption

WithSuggestedCommand records the exact recovery command for an operator or agent.

type ItemSpec

type ItemSpec struct {
	ID            string
	Code          string
	Category      string
	Title         string
	Message       string
	Severity      string
	DataFreshness string
}

ItemSpec names the required fields for one canonical diagnostic item.

type StructuredError

type StructuredError struct {
	Item  contract.DiagnosticItem
	Cause error
}

StructuredError carries a DiagnosticItem while preserving the underlying cause.

func NewStructuredError

func NewStructuredError(item contract.DiagnosticItem, cause error) *StructuredError

NewStructuredError creates a diagnostic-bearing error.

func (*StructuredError) DiagnosticItem

func (e *StructuredError) DiagnosticItem() contract.DiagnosticItem

DiagnosticItem returns the carried diagnostic for common error renderers.

func (*StructuredError) Error

func (e *StructuredError) Error() string

func (*StructuredError) Unwrap

func (e *StructuredError) Unwrap() error

Jump to

Keyboard shortcuts

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