{"record":{"id":"4c9ac3b14de8c219","repo":"hyperledger/fabric","slug":"failed-to-copy-metadatadir-directory-folder-s","errorCode":null,"errorMessage":"failed to copy metadataDir directory folder: %s","messagePattern":"failed to copy metadataDir directory folder: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ccaas_builder/cmd/release/main.go","lineNumber":64,"sourceCode":"\tlogger.Printf(\"::Release phase completed\")\n}\n\nfunc run() error {\n\tif len(os.Args) < 3 {\n\t\treturn errors.New(\"incorrect number of arguments\")\n\t}\n\n\tbuilderOutputDir, releaseDir := os.Args[1], os.Args[2]\n\tconnectionSrcFile := filepath.Join(builderOutputDir, \"/connection.json\")\n\n\tconnectionDir := filepath.Join(releaseDir, \"chaincode/server/\")\n\tconnectionDestFile := filepath.Join(releaseDir, \"chaincode/server/connection.json\")\n\n\tmetadataDir := filepath.Join(builderOutputDir, \"META-INF/statedb\")\n\tmetadataDestDir := filepath.Join(releaseDir, \"statedb\")\n\tif _, err := os.Stat(metadataDir); !os.IsNotExist(err) {\n\t\tif err := copy.Copy(metadataDir, metadataDestDir); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy metadataDir directory folder: %s\", err)\n\t\t}\n\t}\n\n\t// Process and update the connections file\n\t_, err := os.Stat(connectionSrcFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"connection.json not found in source folder: %s\", err)\n\t}\n\n\terr = os.MkdirAll(connectionDir, 0o750)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create target folder for connection.json: %s\", err)\n\t}\n\n\tif err = Copy(connectionSrcFile, connectionDestFile); err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/ccaas_builder/cmd/release/main.go#L46-L82","documentation":"batchRetrieveDocumentMetadata() parses the CouchDB instance URL with url.Parse to build the _all_docs bulk-read URL. If the configured URL is malformed, url.Parse fails and the error is wrapped as 'error parsing CouchDB URL: <url>', aborting the batch document-metadata retrieval used by the ledger during reads/checkpoints.","triggerScenarios":"Any batched key lookup against the state database when couchInstance.url() is malformed — same root causes as error 1071: bad couchDBAddress in core.yaml, unresolved env placeholders, stray whitespace or illegal characters in the host string.","commonSituations":"Misconfigured peer core.yaml, broken docker-compose env substitution for the CouchDB address, IPv6 host without brackets, address copied with a trailing space or scheme included twice (http://http://...).","solutions":["Correct ledger.state.couchDBConfig.couchDBAddress in core.yaml (host:port)","Verify env overrides (CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS) expand properly","Bracket IPv6 literals: [::1]:5984","Test with url.Parse in a snippet using the exact configured string to see the parse error","Recreate the CouchDB instance config and restart the peer"],"exampleFix":"// before\ncouchDBAddress: couchdb.:5984   # invalid host chars\n// after\ncouchDBAddress: couchdb:5984","handlingStrategy":"validation","validationCode":"u, err := url.Parse(couchAddress)\nif err != nil || u.Host == \"\" {\n    return fmt.Errorf(\"invalid couchDBAddress %q: %v\", couchAddress, err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"error parsing CouchDB URL\") {\n    log.Errorf(\"bad CouchDB address: %v\", err) // fix core.yaml and restart\n    return err\n}","preventionTips":["Validate couchDBAddress at peer startup, fail fast","Use net.JoinHostPort for host construction (handles IPv6 brackets)","Check env expansion in docker-compose/K8s configs","Avoid manual string concatenation for the CouchDB address","Snapshot working core.yaml and review diffs after changes"],"tags":["couchdb","url","configuration","fabric"],"backgroundTag":"invalid-couchdb-url","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"}