hyperledger/fabric · error

receiver %T.%s does not exist

Error message

receiver %T.%s does not exist

What it means

Dispatcher.Dispatch uses reflection (MethodByName) to locate a method on the receiver and returns this error when no such method exists. It is the dispatcher's way of reporting an unknown RPC/invocation target before any parameter or proto validation happens.

Source

Thrown at core/dispatcher/dispatcher.go:31

	"google.golang.org/protobuf/proto"
)

// Dispatcher is used to handle the boilerplate proto tasks of unmarshalling inputs and remarshaling outputs
// so that the receiver may focus on the implementation details rather than the proto hassles.
type Dispatcher struct {
	// Protobuf should pass through to Google Protobuf in production paths
	Protobuf Protobuf
}

// Dispatch deserializes the input bytes to the correct type for the method in the receiver, then
// if successful, marshals the output message to bytes and returns it.  On error, it simply returns
// the error.  The method on the receiver must take a single parameter which is a concrete proto
// message type and it should return a proto message and error.
func (d *Dispatcher) Dispatch(inputBytes []byte, methodName string, receiver any) ([]byte, error) {
	method := reflect.ValueOf(receiver).MethodByName(methodName)

	if method == (reflect.Value{}) {
		return nil, errors.Errorf("receiver %T.%s does not exist", receiver, methodName)
	}

	if method.Type().NumIn() != 1 {
		return nil, errors.Errorf("receiver %T.%s has %d parameters but expected 1", receiver, methodName, method.Type().NumIn())
	}

	inputType := method.Type().In(0)
	if inputType.Kind() != reflect.Pointer {
		return nil, errors.Errorf("receiver %T.%s does not accept a pointer as its argument", receiver, methodName)
	}

	if method.Type().NumOut() != 2 {
		return nil, errors.Errorf("receiver %T.%s returns %d values but expected 2", receiver, methodName, method.Type().NumOut())
	}

	if !method.Type().Out(0).Implements(reflect.TypeFor[proto.Message]()) {
		return nil, errors.Errorf("receiver %T.%s does not return a an implementor of proto.Message as its first return value", receiver, methodName)
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Verify methodName matches an exported, pointer-receiver method on the receiver type (case-sensitive)
  2. Ensure the correct receiver implementation is registered for this invocation path and that both orderer/peer binaries are the same version
  3. Add the missing method to the receiver or correct the caller's method name
  4. Add a registry/compile-time check that all dispatched method names exist on their receivers

Example fix

// before
dispatcher.Dispatch(inputBytes, "DeployLablock", handler) // typo
// after
dispatcher.Dispatch(inputBytes, "DeployChaincode", handler)
Defensive patterns

Strategy: validation

Validate before calling

m := reflect.ValueOf(receiver).MethodByName(methodName)
if !m.IsValid() {
    return fmt.Errorf("method %s not implemented by %T", methodName, receiver)
}

Type guard

func receiverHasMethod(receiver any, name string) bool {
    return reflect.ValueOf(receiver).MethodByName(name).IsValid()
}

Try / catch

out, err := dispatcher.Dispatch(inputBytes, methodName, receiver)
if err != nil {
    if strings.Contains(err.Error(), "does not exist") {
        return status.Errorf(codes.NotFound, "unknown method %s", methodName)
    }
    return err
}

Prevention

When it happens

Trigger: Dispatch(inputBytes, methodName, receiver) is called with a methodName that the receiver type does not expose, or the receiver registered for the invocation path does not implement the expected method set (e.g. Invoke dispatches to a handler missing the method).

Common situations: Chaincode/lifecycle handlers renamed or missing between versions; typo'd method name in the invocation request; wrong receiver struct wired into the dispatcher; a client invoking a system chaincode method not present in the deployed binary.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/843c686bac7e7e0b. Report an issue: GitHub.