hyperledger/fabric · error

could not retrieve state for chaincode

Error message

could not retrieve state for chaincode %s on channel %s, error %s

What it means

Returned by getInstantiatedCC when channelState.GetState('lscc', ccid) errors (not merely returns nil) — the state query itself failed for that chaincode on the channel, wrapping the underlying state error with the channel context.

Solutions

  1. Inspect the wrapped error for state DB failures
  2. Retry after restoring state DB availability
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at core/handlers/validation/builtin/v13/lscc_validation_logic.go:618 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at core/handlers/validation/builtin/v13/lscc_validation_logic.go:618

		// all is good!
		return nil
	default:
		return policyErr(fmt.Errorf("VSCC error: committing an invocation of function %s of lscc is invalid", lsccFunc))
	}
}

func (vscc *Validator) getInstantiatedCC(chid, ccid string) (cd *ccprovider.ChaincodeData, exists bool, err error) {
	qe, err := vscc.stateFetcher.FetchState()
	if err != nil {
		err = fmt.Errorf("could not retrieve QueryExecutor for channel %s, error %s", chid, err)
		return
	}
	defer qe.Done()
	channelState := &state{qe}
	bytes, err := channelState.GetState("lscc", ccid)
	if err != nil {
		err = fmt.Errorf("could not retrieve state for chaincode %s on channel %s, error %s", ccid, chid, err)
		return
	}

	if bytes == nil {
		return
	}

	cd = &ccprovider.ChaincodeData{}
	err = proto.Unmarshal(bytes, cd)
	if err != nil {
		err = fmt.Errorf("unmarshalling ChaincodeQueryResponse failed, error %s", err)
		return
	}

	exists = true
	return
}

View on GitHub (pinned to 2736b63f8f)