hyperledger/fabric · error

lscc's state for [%s] not found.

Error message

lscc's state for [%s] not found.

What it means

getCDataForCC queries lscc's state for the chaincode's ChaincodeData; when the returned bytes are nil, the chaincode is not known to lscc on this channel. The error means validation cannot find lifecycle records for the chaincode, so the transaction cannot be validated against a version/policy and is treated as an info-lookup failure (VSCCEndorsementPolicyError family).

Source

Thrown at core/committer/txvalidator/v14/vscc_validator.go:308

	if l == nil {
		return nil, errors.New("nil ledger instance")
	}

	qe, err := l.NewQueryExecutor()
	if err != nil {
		return nil, errors.WithMessage(err, "could not retrieve QueryExecutor")
	}
	defer qe.Done()

	bytes, err := qe.GetState("lscc", ccid)
	if err != nil {
		return nil, &commonerrors.VSCCInfoLookupFailureError{
			Reason: fmt.Sprintf("Could not retrieve state for chaincode %s, error %s", ccid, err),
		}
	}

	if bytes == nil {
		return nil, errors.Errorf("lscc's state for [%s] not found.", ccid)
	}

	cd := &ccprovider.ChaincodeData{}
	err = proto.Unmarshal(bytes, cd)
	if err != nil {
		return nil, errors.Wrap(err, "unmarshalling ChaincodeQueryResponse failed")
	}

	if cd.Vscc == "" {
		return nil, errors.Errorf("lscc's state for [%s] is invalid, vscc field must be set", ccid)
	}

	if len(cd.Policy) == 0 {
		return nil, errors.Errorf("lscc's state for [%s] is invalid, policy field must be set", ccid)
	}

	return cd, err
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Instantiate/deploy the chaincode on the channel (peer chaincode instantiate) before submitting transactions
  2. Verify the client is targeting the correct channel where the chaincode is instantiated
  3. Run peer chaincode list -C <channel> to confirm deployment
  4. Check the state database for lscc corruption and rebuild it if records are missing

Example fix

// before: invoke on channel where cc is not instantiated
await channel.sendTx(contract on 'channelB');
// after
peer chaincode instantiate -C channelA -n mycc -v 1.0 -c '{"Args":["init"]}'
Defensive patterns

Strategy: validation

Validate before calling

const list = await channel.queryInstantiatedChaincodes();
if (!list.some(c => c.name === 'mycc')) throw new Error('mycc not instantiated on channel');

Type guard

function isInstantiated(instantiated, name) {
  return Array.isArray(instantiated) && instantiated.some(c => c.name === name);
}

Try / catch

try { await contract.submitTransaction('move'); } catch (e) {
  if (String(e).includes("not found") || String(e).includes("lscc's state")) { /* instantiate the chaincode, then retry */ }
}

Prevention

When it happens

Trigger: GetInfoForValidate -> getCDataForCC where the state lookup returns nil bytes for ccid — the chaincode was never instantiated/deployed on the channel, or its lscc record was removed.

Common situations: Transaction targets a chaincode not instantiated on that channel; chaincode installed but never instantiated (v1.x); channel mismatch (invoked on wrong channel); state DB corruption dropping lscc keys.

Related errors


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