hyperledger/fabric · error
path to chaincode does not exist: %s
Error message
path to chaincode does not exist: %s
What it means
For a scheme-less path, ValidatePath requires that the local chaincode directory actually exists on the peer's filesystem. If pathExists reports the path does not exist, this error names the raw path that was supplied.
Source
Thrown at core/chaincode/platforms/node/platform.go:67
func (p *Platform) ValidatePath(rawPath string) error {
path, err := url.Parse(rawPath)
if err != nil || path == nil {
return fmt.Errorf("invalid path: %s", err)
}
// Treat empty scheme as a local filesystem path
if path.Scheme == "" {
pathToCheck, err := filepath.Abs(rawPath)
if err != nil {
return fmt.Errorf("error obtaining absolute path of the chaincode: %s", err)
}
exists, err := pathExists(pathToCheck)
if err != nil {
return fmt.Errorf("error validating chaincode path: %s", err)
}
if !exists {
return fmt.Errorf("path to chaincode does not exist: %s", rawPath)
}
}
return nil
}
func (p *Platform) ValidateCodePackage(code []byte) error {
// FAB-2122: Scan the provided tarball to ensure it only contains source-code under
// the src folder.
//
// It should be noted that we cannot catch every threat with these techniques. Therefore,
// the container itself needs to be the last line of defense and be configured to be
// resilient in enforcing constraints. However, we should still do our best to keep as much
// garbage out of the system as possible.
re := regexp.MustCompile(`^(/)?(src|META-INF)/.*`)
is := bytes.NewReader(code)
gr, err := gzip.NewReader(is)
if err != nil {
return fmt.Errorf("failure opening codepackage gzip stream: %s", err)View on GitHub (pinned to 2736b63f8f)
Solutions
- Verify the path exists on the validating host (ls the directory) and fix typos
- Mount or copy the chaincode source into the peer/container filesystem
- Use a URL-style path (with scheme) if the code lives in a VCS and is fetched remotely
Example fix
// before
err := platform.ValidatePath("/opt/chaincode/node/mycc") // not present in container
// after
# docker run -v /opt/chaincode/node/mycc:/opt/chaincode/node/mycc ...
err := platform.ValidatePath("/opt/chaincode/node/mycc") Defensive patterns
Strategy: validation
Validate before calling
if _, err := os.Stat(rawPath); os.IsNotExist(err) { return fmt.Errorf("%q missing on host", rawPath) } Try / catch
if err := platform.ValidatePath(rawPath); err != nil && strings.Contains(err.Error(), "does not exist") {
// mount source or correct the path
} Prevention
- Verify existence on the validating host
- Volume-mount sources in containers
- Check path spelling
When it happens
Trigger: ValidatePath called with a scheme-less path pointing to a directory that is not present on the machine running validation (note: this is the node platform, so a Go-path with a scheme like github.com/... is accepted, but a bare non-existent local path fails).
Common situations: Chaincode source not deployed/pulled to the peer host; typo in the path; running in a container where the source directory was not volume-mounted; switching between hosts where paths differ.
Related errors
- error obtaining absolute path of the chaincode: %s
- failed to calculate relative path for %s
- invalid path: %s
- error validating chaincode path: %s
- error reading chaincode install package at %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/492872ab799b5855.
Report an issue: GitHub.