{"record":{"id":"b352b91af52090b4","repo":"juicedata/juicefs","slug":"marshal-worker-config-s","errorCode":null,"errorMessage":"marshal worker config: %s","messagePattern":"marshal worker config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sync/cluster.go","lineNumber":398,"sourceCode":"\t\t\tworkerArgs[i] = utils.RemovePassword(config.clusterSource)\n\t\t\tfoundSource = true\n\t\t}\n\t\tif arg == config.clusterDestination {\n\t\t\tworkerArgs[i] = utils.RemovePassword(config.clusterDestination)\n\t\t\tfoundDestination = true\n\t\t}\n\t}\n\tif !foundSource || !foundDestination {\n\t\treturn nil, nil, fmt.Errorf(\"can't locate source or destination in command arguments\")\n\t}\n\n\tpayload, err := json.Marshal(clusterWorkerConfig{\n\t\tSource:      config.clusterSource,\n\t\tDestination: config.clusterDestination,\n\t\tEnv:         config.Env,\n\t})\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"marshal worker config: %s\", err)\n\t}\n\n\targs := []string{host, path}\n\targs = append(args, workerArgs...)\n\targs = append(args, \"--manager\", address)\n\tif !config.Verbose && !config.Quiet {\n\t\targs = append(args, \"-q\")\n\t}\n\treturn shellescape.EscapeArgs(args), payload, nil\n}\n\n// ReadClusterWorkerConfig reads storage URLs and environment variables from worker stdin.\nfunc ReadClusterWorkerConfig(r io.Reader) (string, string, map[string]string, error) {\n\tdata, err := io.ReadAll(io.LimitReader(r, maxClusterWorkerConfigSize+1))\n\tif err != nil {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"read worker config: %s\", err)\n\t}\n\tif len(data) > maxClusterWorkerConfigSize {","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/sync/cluster.go#L380-L416","documentation":"After locating source/destination, prepareWorkerCommand serializes the clusterWorkerConfig (source/destination URLs and env) to JSON to pipe to the worker over stdin. This error wraps any json.Marshal failure. In practice it is nearly impossible for this struct (three string/map fields), so it indicates an unexpected internal serialization problem.","triggerScenarios":"json.Marshal of the clusterWorkerConfig{Source, Destination, Env} struct returns an error — practically only if custom marshaling is added to the struct or Env contains a type that cannot be marshaled after a code change.","commonSituations":"Custom builds or patches that add unsupported field types (e.g. channels, funcs, NaN floats) to clusterWorkerConfig or Env; standard releases essentially never emit this.","solutions":["Inspect the wrapped error (%s) to identify the unmarshalable value","Check for local modifications adding fields of unsupported types (chan, func, complex) to clusterWorkerConfig and change them to serializable types","Ensure Env map values are plain strings, not custom types"],"exampleFix":"// before\nEnv: map[string]CustomType{...} // unmarshalable\n// after\nEnv: map[string]string{\"KEY\": \"value\"}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"payload, err := json.Marshal(cfg)\nif err != nil {\n\treturn fmt.Errorf(\"marshal worker config: %s\", err)\n}","preventionTips":["Keep clusterWorkerConfig fields limited to JSON-serializable types (strings, maps of strings)","Never add chan/func/complex fields to config structs piped between processes"],"tags":["sync","json","serialization","cluster"],"backgroundTag":"json-marshal-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}