{"record":{"id":"ef9e2fa933179b41","repo":"hyperledger/fabric","slug":"error-obtaining-absolute-path-of-the-chaincode-s","errorCode":null,"errorMessage":"error obtaining absolute path of the chaincode: %s","messagePattern":"error obtaining absolute path of the chaincode: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/node/platform.go","lineNumber":59,"sourceCode":"}\n\n// Name returns the name of this platform\nfunc (p *Platform) Name() string {\n\treturn pb.ChaincodeSpec_NODE.String()\n}\n\n// ValidatePath validates Go chaincodes\nfunc (p *Platform) ValidatePath(rawPath string) error {\n\tpath, err := url.Parse(rawPath)\n\tif err != nil || path == nil {\n\t\treturn fmt.Errorf(\"invalid path: %s\", err)\n\t}\n\n\t// Treat empty scheme as a local filesystem path\n\tif path.Scheme == \"\" {\n\t\tpathToCheck, err := filepath.Abs(rawPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error obtaining absolute path of the chaincode: %s\", err)\n\t\t}\n\n\t\texists, err := pathExists(pathToCheck)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error validating chaincode path: %s\", err)\n\t\t}\n\t\tif !exists {\n\t\t\treturn fmt.Errorf(\"path to chaincode does not exist: %s\", rawPath)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (p *Platform) ValidateCodePackage(code []byte) error {\n\t// FAB-2122: Scan the provided tarball to ensure it only contains source-code under\n\t// the src folder.\n\t//\n\t// It should be noted that we cannot catch every threat with these techniques.  Therefore,","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/node/platform.go#L41-L77","documentation":"When the parsed path has no scheme (treated as a local filesystem path), ValidatePath converts it to an absolute path with filepath.Abs. If that conversion fails (rare; e.g. working directory issues), this error wraps the cause.","triggerScenarios":"ValidatePath called with a scheme-less path while filepath.Abs fails — typically because os.Getwd fails, e.g. the current working directory was deleted or is inaccessible.","commonSituations":"Process started in a directory that was subsequently removed (common in containers/CI); running with a deleted cwd; extremely long paths exceeding system limits.","solutions":["Ensure the process has a valid, existing working directory before calling","Pass an already-absolute path so filepath.Abs needs no cwd resolution","Restart the process from a valid working directory"],"exampleFix":"// before\nos.Chdir(\"/tmp/deleted-dir\") // cwd removed\nerr := platform.ValidatePath(\"chaincode/node/mycc\")\n// after\nerr := platform.ValidatePath(\"/opt/chaincode/node/mycc\") // absolute path","handlingStrategy":"validation","validationCode":"if _, err := os.Getwd(); err != nil { return errors.New(\"invalid cwd; pass absolute paths\") }","typeGuard":null,"tryCatchPattern":"if err := platform.ValidatePath(rawPath); err != nil && strings.Contains(err.Error(), \"error obtaining absolute path\") {\n    // retry with an absolute path\n}","preventionTips":["Use absolute paths","Never delete the runtime cwd"],"tags":["chaincode","node","filesystem","path"],"backgroundTag":"invalid-working-directory","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}