hyperledger/fabric · error

invalid private name format: %s

Error message

invalid private name format: %s

What it means

extractChaincodeNameAndSequence expects the private metadata key to be exactly '<chaincodeName>#<sequence>'. If splitting on '#' does not yield exactly two parts, the key is malformed and this error is thrown. It indicates lifecycle state contains a key that does not conform to the naming convention.

Source

Thrown at core/chaincode/lifecycle/lifecycle.go:683

		}
	}

	return &ApprovedChaincodeDefinition{
		Sequence:        sequence,
		EndorsementInfo: ccParameters.EndorsementInfo,
		ValidationInfo:  ccParameters.ValidationInfo,
		Collections:     ccParameters.Collections,
		Source:          ccsrc,
	}, nil
}

func extractChaincodeNameAndSequence(privateName string) (string, int64, error) {
	var ccname string
	var sequence int64

	split := strings.Split(privateName, "#")
	if len(split) != 2 {
		return "", 0, errors.Errorf("invalid private name format: %s", privateName)
	}

	ccname = split[0]
	sequenceStr := split[1]

	var err error
	sequence, err = strconv.ParseInt(sequenceStr, 10, 64)
	if err != nil {
		return "", 0, errors.WithMessagef(err, "invalid sequence number in private name: %s", privateName)
	}

	return ccname, sequence, nil
}

// ErrNamespaceNotDefined is the error returned when a namespace
// is not defined. This indicates that the chaincode definition
// has not been committed.
type ErrNamespaceNotDefined struct {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Locate the malformed key in the peer state DB (e.g. via couchdb views) and remove or fix it
  2. Rebuild the peer state from channel snapshots or rejoin the peer to the channel
  3. Ensure all peers run a supported Fabric version with a consistent lifecycle implementation
  4. Restore from a known-good peer backup
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate expected key format before iterating state keys
func isValidPrivateName(k string) bool {
  parts := strings.Split(k, "#")
  return len(parts) == 2 && parts[0] != "" && isInt(parts[1])
}

Try / catch

_, err := extractChaincodeNameAndSequence(key)
if err != nil {
  log.Warnf("skipping malformed lifecycle key %q: %v", key, err)
  continue
}

Prevention

When it happens

Trigger: QueryApprovedChaincodeDefinitions iterates all keys under ChaincodeSourcesName in the org state and a key lacks the single '#' separator (zero or multiple '#'), or has an empty/non-numeric tail.

Common situations: Corrupt or manually edited peer state DB; keys written by an incompatible lifecycle implementation; leftover keys from state migration between Fabric versions.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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