canopy-network/canopy · error
field number not found
Error message
field number not found
What it means
Sentinel error ErrFieldNotFound returned by codec.GetRawProtoField when the requested field number is absent from the protobuf wire bytes. In proto3 an absent scalar field is the zero value, so this is not a parse failure; callers detect it with errors.Is and treat the field as empty (as fsm/indexer.go:466 does, returning "", nil). The wrapped value appended at lib/codec/codec.go:118 is the missing field number.
Source
Thrown at lib/codec/codec.go:17
package codec
import (
"encoding/json"
"errors"
"fmt"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
// ErrFieldNotFound is returned by GetRawProtoField when the requested field
// number is absent from the wire bytes. In proto3, absent scalar fields
// represent the zero value, so callers that expect zero-valued fields
// (e.g. Pool{Id:0}, Account{Address:nil}) should detect this via errors.Is
// and treat the field as empty rather than as a parse error.
var ErrFieldNotFound = errors.New("field number not found")
// BinaryCodec is an interface model that defines the requirements for binary encoding and decoding
// A binary encoder converts data into a compact, non-human-readable binary format, which is highly
// efficient in terms of both storage size and speed for serialization and deserialization
type BinaryCodec interface {
Marshal(message any) ([]byte, error)
Unmarshal(data []byte, ptr any) error
ToAny(proto.Message) (*anypb.Any, error)
FromAny(*anypb.Any) (proto.Message, error)
}
// JSONCodec is an interface model that defines requirements for json encoding and decoding
// converts data into a human-readable text format (JSON) which can be more friendly but less performant
type JSONCodec interface {
json.Marshaler
json.Unmarshaler
}
View on GitHub (pinned to ee8197d91d)
Solutions
- Use errors.Is(err, codec.ErrFieldNotFound) and treat the field as its zero value instead of failing.
- If the field should always exist, inspect the encoded proto to see why the field was omitted (unset in proto3 or wrong field number requested).
- Confirm the caller passes the correct field number registered for that proto message.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at lib/codec/codec.go:17 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of canopy-network/canopy@ee8197d91d (2026-09-06).
Data as JSON: /api/errors/c482b79b46afcad3.
Report an issue: GitHub.