{"record":{"id":"7314f46cda27eaf3","repo":"hyperledger/fabric","slug":"invalid-path-s","errorCode":null,"errorMessage":"invalid path: %s","messagePattern":"invalid path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/java/platform.go","lineNumber":40,"sourceCode":"\t\"github.com/hyperledger/fabric/core/chaincode/platforms/util\"\n)\n\nvar logger = flogging.MustGetLogger(\"chaincode.platform.java\")\n\n// Platform for java chaincodes in java\ntype Platform struct{}\n\n// Name returns the name of this platform\nfunc (p *Platform) Name() string {\n\treturn pb.ChaincodeSpec_JAVA.String()\n}\n\n// ValidatePath validates the java chaincode paths\nfunc (p *Platform) ValidatePath(rawPath string) error {\n\tpath, err := url.Parse(rawPath)\n\tif err != nil || path == nil {\n\t\tlogger.Errorf(\"invalid chaincode path %s %v\", rawPath, err)\n\t\treturn fmt.Errorf(\"invalid path: %s\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (p *Platform) ValidateCodePackage(code []byte) error {\n\t// File to be valid should match first RegExp and not match second one.\n\tfilesToMatch := regexp.MustCompile(`^(/)?src/((src|META-INF)/.*|(build\\.gradle|settings\\.gradle|pom\\.xml))`)\n\tfilesToIgnore := regexp.MustCompile(`.*\\.class$`)\n\tis := bytes.NewReader(code)\n\tgr, err := gzip.NewReader(is)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failure opening codepackage gzip stream: %s\", err)\n\t}\n\ttr := tar.NewReader(gr)\n\n\tfor {\n\t\theader, err := tr.Next()","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/java/platform.go#L22-L58","documentation":"The Java platform's ValidatePath parses the raw chaincode path as a URL; if url.Parse fails or returns nil, it returns 'invalid path: %s'. Unlike other platforms, the path must at least be a parseable URI.","triggerScenarios":"Calling ValidatePath with a malformed path string that url.Parse cannot handle, e.g. containing invalid characters like unescaped control chars, bad percent-encodings, or whitespace.","commonSituations":"Users passing Windows-style or shell-quoted paths, paths copied with trailing spaces, or strings containing characters URL parsing rejects.","solutions":["Supply a plain, well-formed relative path (e.g. 'src/java-chaincode') without special characters.","Escape or remove characters invalid in URLs (% not followed by hex, control chars).","Trim whitespace from the path before submission.","Check the peer logs — the same parse error is logged with details."],"exampleFix":"// before\nValidatePath(\"my cc/path%zz\")\n// after\nValidatePath(\"my-cc/path\")","handlingStrategy":"validation","validationCode":"func validJavaPath(p string) bool {\n\tif p == \"\" { return false }\n\t_, err := url.Parse(p)\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":"if err := javaPlatform.ValidatePath(rawPath); err != nil {\n\tif strings.Contains(err.Error(), \"invalid path\") {\n\t\t// sanitize: trim whitespace, remove invalid URL characters\n\t}\n}","preventionTips":["Trim whitespace before submitting paths","Avoid control characters and bad percent-encodings in paths","Use simple relative POSIX-style paths for Java chaincode"],"tags":["chaincode","java","url-parsing","hyperledger-fabric"],"backgroundTag":"invalid-chaincode-path","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"}