Documentation
¶
Overview ¶
Package decodeerr reduces an encoding/json/v2 decode error to the parts of it that are safe and stable to hand a client (SONNY-4078).
The Error() text of a *json.SemanticError is neither: json/v2 picks its modal verb ("cannot" vs "unable to") once per process, by design, so the same refusal reads differently from one server process to the next, and it names the Go type being decoded into. Classify keeps only the JSON pointer of the offending value and a fixed cause phrase chosen from the error's sentinel, so the refusal is identical in every process and carries nothing about the server's implementation. Callers log the raw error separately. Code generated by apic; DO NOT EDIT.
Index ¶
Constants ¶
const ( // UnknownMember: an object member the target type does not declare // (json.ErrUnknownName under RejectUnknownMembers). UnknownMember = "unknown member" // DuplicateMember: an object member named twice (jsontext.ErrDuplicateName). DuplicateMember = "duplicate member" // InvalidType: a JSON value of the wrong kind for its target (a string // where a number is declared, an array where an object is, ...). InvalidType = "invalid type" // InvalidValue: a JSON value of the right kind that the target refuses // (an out-of-range number, a custom unmarshaler's refusal, ...). InvalidValue = "invalid value" // MalformedJSON: input that is not valid JSON (truncated, bad syntax, // invalid UTF-8, ...). MalformedJSON = "malformed JSON" )
Stable cause phrases. They are part of the client-facing contract: change one only as a breaking change.
const MaxPointerBytes = 256
MaxPointerBytes bounds the JSON pointer echoed back to a client. The pointer is built from client-supplied member names, so an unbounded one would let a request make the refusal arbitrarily large; a longer pointer is cut at MaxPointerBytes and ends in TruncationMarker, which marks it as no longer a usable pointer.
const TruncationMarker = "...(truncated)"
TruncationMarker ends a pointer that was cut at MaxPointerBytes.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.