bson

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package bson declares the error codes and the sentinels of the BSON codec, internal/service/data/codec/bson — range 0.3.36.* (ADR 0021 service/data/codec/bson block).

The codes live in the core at the path that mirrors the package emitting them (ADR 0160 §2) and keep the values they were allocated with: the LL byte 3 records the layer that allocated the range, not the directory that declares it today (ADR 0160 §3). Nothing here encodes or decodes — the mechanism, and the constructors that attach a failure's detail, stay in the service package.

Package bson — the sentinel *errs.Error values, one per code. Each Reason derives from its var name or from its Code constant (ADR 0020); the Public and Private texts are the ones the service package always emitted, so moving the declaration changed no rendering.

Index

Constants

View Source
const CodeBSONDepthExceeded errs.Code = 0x00_03_24_04 // 0.3.36.4

CodeBSONDepthExceeded identifies a document or value nested deeper than maxBSONNestedLevels, in either direction (CWE-674 stack-exhaustion defence; on the encode side it is also what a cyclic value runs into).

View Source
const CodeBSONMarshalFailed errs.Code = 0x00_03_24_01 // 0.3.36.1

CodeBSONMarshalFailed identifies a value Marshal or Append cannot encode: a top level that is not a document, a type BSON has no representation for, a string that is not UTF-8, a key holding a NUL, or an error a MarshalBSON method returned.

View Source
const CodeBSONSizeExceeded errs.Code = 0x00_03_24_03 // 0.3.36.3

CodeBSONSizeExceeded identifies an Unmarshal input whose length exceeds the 10 MiB hard cap (CWE-400 memory-exhaustion defence before any byte is read).

View Source
const CodeBSONUnmarshalFailed errs.Code = 0x00_03_24_02 // 0.3.36.2

CodeBSONUnmarshalFailed identifies input Unmarshal refuses: bytes that are not one well-formed BSON document, or a value the target cannot hold.

View Source
const CodeBSONValueInvalid errs.Code = 0x00_03_24_05 // 0.3.36.5

CodeBSONValueInvalid identifies a BSON value type that cannot be built from what it was given: a malformed ObjectID hex string, a decimal128 string that is not a number or not exactly representable, a JSON form of either that is neither of the shapes accepted.

Variables

View Source
var (
	// MarshalFailed marks a value Marshal or Append cannot encode.
	MarshalFailed = errs.Define(CodeBSONMarshalFailed, "BSON_MARSHAL_FAILED",
		"BSON encoding failed",
		"service/data/codec/bson: the value has no BSON encoding")

	// UnmarshalFailed marks input Unmarshal refuses.
	UnmarshalFailed = errs.Define(CodeBSONUnmarshalFailed, "BSON_UNMARSHAL_FAILED",
		"BSON decoding failed",
		"service/data/codec/bson: the input is not a well-formed BSON document the target can hold")

	// SizeExceeded marks an Unmarshal input over the 10 MiB hard cap.
	SizeExceeded = errs.Define(CodeBSONSizeExceeded, "BSON_SIZE_EXCEEDED",
		"BSON input exceeds size limit",
		"service/data/codec/bson: len(data) exceeds maxBSONBytes")

	// DepthExceeded marks a document or value nested deeper than the codec
	// reads or writes.
	DepthExceeded = errs.Define(CodeBSONDepthExceeded, "BSON_DEPTH_EXCEEDED",
		"BSON nesting depth exceeds limit",
		"service/data/codec/bson: nesting exceeds maxBSONNestedLevels")

	// ValueInvalid marks a BSON value type that cannot be built from its input.
	ValueInvalid = errs.Define(CodeBSONValueInvalid, "BSON_VALUE_INVALID",
		"BSON value is invalid",
		"service/data/codec/bson: the input does not describe a value of this BSON type")
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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