{"record":{"id":"322c5b824b00224e","repo":"hyperledger/fabric","slug":"incorrect-number-of-arguments","errorCode":null,"errorMessage":"incorrect number of arguments","messagePattern":"incorrect number of arguments","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ccaas_builder/cmd/release/main.go","lineNumber":51,"sourceCode":"\tClientAuth  bool   `json:\"client_auth_required\"`\n\tRootCert    string `json:\"root_cert\"`\n\tClientKey   string `json:\"client_key\"`\n\tClientCert  string `json:\"client_cert\"`\n}\n\nfunc main() {\n\tlogger.Println(\"::Release\")\n\n\tif err := run(); err != nil {\n\t\tlogger.Printf(\"::Error: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\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)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/ccaas_builder/cmd/release/main.go#L33-L69","documentation":"ApplyDatabaseSecurity() serializes the databaseSecurity struct with json.Marshal before PUTting it to the database's _security endpoint. If marshalling fails the error is wrapped (with a slightly misleading 'unmarshalling' wording) as 'error unmarshalling json data' and the security update is aborted. json.Marshal only fails for unsupported types (channels, funcs, cyclic structures), so this almost always indicates a bug in the constructed databaseSecurity value rather than a server problem.","triggerScenarios":"Calling ApplyDatabaseSecurity() with a databaseSecurity struct that contains a value json.Marshal cannot encode — e.g. cyclic pointer references, a channel/func field, or NaN/infinite float values inside the struct.","commonSituations":"Custom code building security structs with non-serializable fields; plugins or chaincode-injected values with cycles; Go version/type changes introducing unsupported types.","solutions":["Inspect the databaseSecurity value passed in; remove any channel, func, or cyclic reference","Ensure Admins/Members Names/Roles are plain []string slices","Reproduce with json.Marshal(databaseSecurity) in isolation to see the underlying unsupported-type error","If extending the struct, add custom MarshalJSON for unsupported fields","Report as a Fabric bug if it occurs with stock code — stock structs should never fail to marshal"],"exampleFix":"// before\ntype databaseSecurity struct {\n    Admins admins `json:\"admins\"`\n    Conn   net.Conn `json:\"-\"` // func/channel-like field breaks Marshal\n}\n// after\ntype databaseSecurity struct {\n    Admins admins `json:\"admins\"`\n    // drop non-serializable fields entirely\n}","handlingStrategy":"validation","validationCode":"if _, err := json.Marshal(databaseSecurity); err != nil {\n    return fmt.Errorf(\"security struct not marshallable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := db.ApplyDatabaseSecurity(sec)\nif err != nil && strings.Contains(err.Error(), \"json data\") {\n    return fmt.Errorf(\"invalid security struct (check for channels/funcs/cycles): %w\", err)\n}","preventionTips":["Keep databaseSecurity fields limited to strings and []string","Never store channels, funcs, or cyclic pointers in request structs","Unit-test custom security-struct construction with json.Marshal","Avoid fork modifications to the security struct","Treat occurrences with stock code as an upstream bug report"],"tags":["couchdb","json","marshal","fabric"],"backgroundTag":"json-marshal-failed","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"}