restrictions

package
v1.37.13 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultErrorMessageTemplate = "{value} is not allowed for {restriction}. Allowed values: {allowed}."

DefaultErrorMessageTemplate is rendered when RESTRICTIONS_ERROR_MESSAGE is unset. Tier-specific copy lives only in operator overrides, not OSS.

View Source
const ErrorCode = "CONFIG_NOT_ALLOWED"

ErrorCode is the stable machine identifier for restriction violations in the HTTP body (`errorCode`) and the gRPC FailedPrecondition Reason.

Variables

This section is empty.

Functions

func RenderTemplate

func RenderTemplate(template string, restriction RestrictionName, value string, allowed []string) string

RenderTemplate substitutes {restriction}, {value}, {allowed} in the template (empty = default). Allowed is sorted to keep the wire output deterministic regardless of operator-configured order.

Types

type RestrictionName

type RestrictionName string

RestrictionName is the stable wire identifier for which restriction rejected a value. Surfaces in JSON / gRPC error metadata.

const (
	RestrictionVectorIndexType RestrictionName = "vector_index_type"
	RestrictionCompression     RestrictionName = "compression"
)

type ViolationError

type ViolationError struct {
	Restriction     RestrictionName
	Value           string
	Allowed         []string
	RenderedMessage string
}

ViolationError is the wire-protocol-agnostic error raised when a class config violates an operator allow-list. The HTTP layer maps to 422 + RestrictionViolationResponse; the gRPC layer maps to FailedPrecondition with the same fields as ErrorInfo metadata.

func AsViolation

func AsViolation(err error) (*ViolationError, bool)

AsViolation unwraps err to a *ViolationError if its chain contains one.

func NewViolationError

func NewViolationError(template string, restriction RestrictionName, value string, allowed []string) *ViolationError

NewViolationError builds a *ViolationError with its message rendered from the template (empty = default). Free function (no Manager type) so callers don't pick up an extra dependency.

func (*ViolationError) Error

func (e *ViolationError) Error() string

Jump to

Keyboard shortcuts

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