hyperledger/fabric · error

signer cannot be nil

Error message

signer cannot be nil

What it means

signProposal requires a Signer (an identity whose private key signs the marshaled proposal bytes). It returns this error when the signer argument is nil. Without a signer the peer CLI cannot authenticate the lifecycle proposal to the endorser.

Source

Thrown at internal/peer/lifecycle/chaincode/common.go:54

// Signer defines the interface needed for signing messages
type Signer interface {
	Sign(msg []byte) ([]byte, error)
	Serialize() ([]byte, error)
}

// Writer defines the interface needed for writing a file
type Writer interface {
	WriteFile(string, string, []byte) error
}

func signProposal(proposal *pb.Proposal, signer Signer) (*pb.SignedProposal, error) {
	// check for nil argument
	if proposal == nil {
		return nil, errors.New("proposal cannot be nil")
	}

	if signer == nil {
		return nil, errors.New("signer cannot be nil")
	}

	proposalBytes, err := proto.Marshal(proposal)
	if err != nil {
		return nil, errors.Wrap(err, "error marshaling proposal")
	}

	signature, err := signer.Sign(proposalBytes)
	if err != nil {
		return nil, err
	}

	return &pb.SignedProposal{
		ProposalBytes: proposalBytes,
		Signature:     signature,
	}, nil
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Ensure the peer's local MSP is configured (FABRIC_CFG_PATH, mspConfigPath, local msp dirs with admincerts/signcerts/keystore)
  2. Verify the signer lookup that precedes signProposal did not return (nil, nil) and ignore its error
  3. Pass a valid Signer implementation when calling the library directly

Example fix

// before
sp, err := signProposal(proposal, nil)
// after
signer, err := localmsp.NewSigner()
if err != nil {
    return err
}
sp, err := signProposal(proposal, signer)
Defensive patterns

Strategy: validation

Validate before calling

signer, err := localmsp.NewSigner()
if err != nil {
    return err
}
if signer == nil {
    return errors.New("no signing identity configured")
}
sp, err := signProposal(proposal, signer)

Type guard

func hasSigner(s Signer) bool { return s != nil }

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "signer cannot be nil") {
        // verify local MSP configuration (FABRIC_CFG_PATH, mspConfigPath)
    }
}

Prevention

When it happens

Trigger: Approve, ReadinessCheck, Commit, Get, Install, or Query invoke signProposal with a nil signer — i.e., no signing identity was obtained (e.g. signer retrieval failed but error was ignored, or msp-based signer construction returned nil).

Common situations: Running peer lifecycle commands without a properly configured local MSP (peer context missing core.yaml local mspadmincerts/keystore), or embedding the library without wiring a signing identity.

Related errors


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