{"record":{"id":"8c5c1fe2aa0c5b25","repo":"juicedata/juicefs","slug":"failed-to-chown-object-s","errorCode":null,"errorMessage":"failed to chown object %s","messagePattern":"failed to chown object (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/objbench.go","lineNumber":1099,"sourceCode":"\t\t\t}\n\t\t\tcnt, err := io.ReadAll(r)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to get multipart upload file: %v\", err)\n\t\t\t}\n\t\t\tif !bytes.Equal(cnt, bytes.Join(content, nil)) {\n\t\t\t\treturn fmt.Errorf(\"the content of the multipart upload file is incorrect\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\treturn utils.ErrNotSUP\n\t})\n\n\tfunFSCase(\"change owner/group\", func() error {\n\t\tif (strings.HasPrefix(blob.String(), \"file://\") || strings.HasPrefix(blob.String(), \"jfs://\")) && os.Getuid() != 0 {\n\t\t\treturn errors.New(\"root required\")\n\t\t}\n\t\tif err := fi.Chown(key, \"nobody\", groupName); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to chown object %s\", err)\n\t\t}\n\t\tif objInfo, err := blob.Head(ctx, key); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to head object %s\", err)\n\t\t} else if info, ok := objInfo.(object.File); ok {\n\t\t\tif info.Owner() != \"nobody\" {\n\t\t\t\treturn fmt.Errorf(\"expect owner nobody but got %s\", info.Owner())\n\t\t\t}\n\t\t\tif info.Group() != groupName {\n\t\t\t\treturn fmt.Errorf(\"expect group %s but got %s\", groupName, info.Group())\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\tfunFSCase(\"change permission\", func() error {\n\t\tif err := fi.Chmod(key, 0777); err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":1081,"sourceCodeEnd":1117,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/objbench.go#L1081-L1117","documentation":"Returned by the 'change owner/group' funFS case when fi.Chown(key, \"nobody\", groupName) fails. This exercises filesystem-style ownership on file:// or jfs:// style backends; a failure means the underlying chown syscall/operation was refused — insufficient privileges, unsupported backend, or the user/group ('nobody'/groupName) does not exist. Note the format string uses %s with the error, printing the error text instead of a label.","triggerScenarios":"Running objbench FS cases as a non-root user on file:// or jfs:// (this is partially pre-checked), chown to 'nobody' or a nonexistent group, or a backend whose FileSystem implementation does not support Chown.","commonSituations":"Benchmark run without sudo against a local file system, container without CAP_CHOWN, groupName not defined on the host (/etc/group), or FUSE mount not allowing ownership changes by the mounting user.","solutions":["Run objbench as root (or with CAP_CHOWN) when testing file:// or jfs:// backends.","Verify 'nobody' and the groupName exist on the system (id nobody; getent group <groupName>).","Confirm the backend FileSystem implements Chown; skip the case for backends lacking ownership support.","Fix the message to embed the underlying error with %w for diagnosis."],"exampleFix":"// before\nif err := fi.Chown(key, \"nobody\", groupName); err != nil {\n\treturn fmt.Errorf(\"failed to chown object %s\", err)\n}\n// after\nif err := fi.Chown(key, \"nobody\", groupName); err != nil {\n\treturn fmt.Errorf(\"failed to chown object: %w\", err)\n}","handlingStrategy":"validation","validationCode":"if (strings.HasPrefix(blob.String(), \"file://\") || strings.HasPrefix(blob.String(), \"jfs://\")) && os.Getuid() != 0 {\n\treturn errors.New(\"root required\")\n}\nif _, err := user.Lookup(\"nobody\"); err != nil {\n\treturn fmt.Errorf(\"user nobody missing: %w\", err)\n}\nif _, err := user.LookupGroup(groupName); err != nil {\n\treturn fmt.Errorf(\"group %s missing: %w\", groupName, err)\n}","typeGuard":null,"tryCatchPattern":"if err := fi.Chown(key, \"nobody\", groupName); err != nil {\n\treturn fmt.Errorf(\"failed to chown object: %w\", err)\n}","preventionTips":["Run FS-owner cases as root or with CAP_CHOWN","Ensure 'nobody' and the target group exist on the host","Skip ownership cases on backends without Chown support","Wrap errors with %w so root causes are visible"],"tags":["permissions","chown","filesystem"],"backgroundTag":"permission-denied","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"}