hyperledger/fabric · error

could not determine whether chaincode install package '%s' e

Error message

could not determine whether chaincode install package '%s' exists

What it means

Store.Load wraps errors from ReadWriter.Exists when it cannot determine whether the package file exists. This is not 'package not found' (that returns CodePackageNotFoundErr) — it means the existence check itself failed, typically an OS-level path/stat error.

Source

Thrown at core/chaincode/persistence/persistence.go:188

	}

	if err := s.ReadWriter.WriteFile(s.Path, ccInstallPkgFileName, ccInstallPkg); err != nil {
		err = errors.Wrapf(err, "error writing chaincode install package to %s", ccInstallPkgFilePath)
		logger.Error(err.Error())
		return "", err
	}

	return packageID, nil
}

// Load loads a persisted chaincode install package bytes with
// the given packageID.
func (s *Store) Load(packageID string) ([]byte, error) {
	ccInstallPkgPath := filepath.Join(s.Path, CCFileName(packageID))

	exists, err := s.ReadWriter.Exists(ccInstallPkgPath)
	if err != nil {
		return nil, errors.Wrapf(err, "could not determine whether chaincode install package '%s' exists", packageID)
	}
	if !exists {
		return nil, &CodePackageNotFoundErr{
			PackageID: packageID,
		}
	}

	ccInstallPkg, err := s.ReadWriter.ReadFile(ccInstallPkgPath)
	if err != nil {
		err = errors.Wrapf(err, "error reading chaincode install package at %s", ccInstallPkgPath)
		return nil, err
	}

	return ccInstallPkg, nil
}

// Delete deletes a persisted chaincode.  Note, there is no locking,
// so this should only be performed if the chaincode has already

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Fix filesystem permissions on the chaincodes directory path
  2. Retry Load after storage recovers if the error is transient I/O
  3. Verify the packageID is a valid hash and resolves to a sane filename
  4. If the package truly may be absent, handle CodePackageNotFoundErr separately from this wrap
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(filepath.Join(storePath, filename)); err != nil && !os.IsNotExist(err) { return fmt.Errorf("stat failed: %w", err) }

Try / catch

pkg, err := store.Load(packageID)
if err != nil {
  var nf *persistence.CodePackageNotFoundErr
  if errors.As(err, &nf) { /* reinstall */ }
  return fmt.Errorf("existence check failed: %w", err)
}

Prevention

When it happens

Trigger: Calling Load(packageID) (e.g. during chaincode build/launch) when the filepath stat underlying Exists fails: path too long, permission denied on a parent directory, or I/O error.

Common situations: Directory permissions broken mid-flight; storage backend error on network volumes; packageID containing characters producing an invalid/overlong filename via CCFileName.

Related errors


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