{"record":{"id":"511be2e92105cd08","repo":"juicedata/juicefs","slug":"invalid-key-s-fail-to-parse-size","errorCode":null,"errorMessage":"invalid key %s, fail to parse size","messagePattern":"invalid key (.+?), fail to parse size","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/meta/redis.go","lineNumber":4198,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tclose(pendingKeys)\n\t}()\n\n\tfor key := range pendingKeys {\n\t\tps := strings.Split(key[1:], \"_\")\n\t\tif len(ps) != 2 {\n\t\t\treturn fmt.Errorf(\"invalid key %s\", key)\n\t\t}\n\t\tid, err := strconv.ParseUint(ps[0], 10, 64)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"invalid key %s, fail to parse id\", key)\n\t\t}\n\t\tsize, err := strconv.ParseUint(ps[1], 10, 64)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"invalid key %s, fail to parse size\", key)\n\t\t}\n\t\tclean, err := scan(id, uint32(size))\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"scan pending slices\")\n\t\t}\n\t\tif clean {\n\t\t\t// TODO: m.deleteSlice(id, uint32(size))\n\t\t\t// avoid lint warning\n\t\t\t_ = clean\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (m *redisMeta) scanPendingFiles(ctx Context, scan pendingFileScan) error {\n\tif scan == nil {\n\t\treturn nil\n\t}","sourceCodeStart":4180,"sourceCodeEnd":4216,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis.go#L4180-L4216","documentation":"Same GC pending-slice scan as the \"fail to parse id\" error, but here the size portion of a \"<id>_<size>\" pending-slice key could not be parsed with strconv.ParseUint. The library throws it because a slice size must be a valid uint64 to delete or scan the slice; a malformed size means the key is corrupt or foreign.","triggerScenarios":"`juicefs gc` scanPendingSlices encounters a key whose second underscore-separated segment is not a decimal uint64 (e.g. \"123_abc\"), after the id segment parsed successfully.","commonSituations":"Corrupted or manually inserted Redis keys; data from an incompatible older key encoding; external tools writing into the JuiceFS keyspace.","solutions":["Inspect and remove the malformed key via redis-cli (key name is in the message).","Verify no other applications share the Redis DB with JuiceFS.","Re-run `juicefs gc` after cleaning the keyspace.","Check for interrupted upgrades between JuiceFS versions that changed pending-slice encoding."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the size component of a pending-slice key before GC processes it:\nparts := strings.Split(key, \"_\")\nif len(parts) == 2 {\n    if _, err := strconv.ParseUint(parts[1], 10, 64); err != nil { /* corrupt */ }\n}","typeGuard":"func validSliceSize(key string) bool {\n    i := strings.LastIndex(key, \"_\")\n    if i < 0 { return false }\n    _, err := strconv.ParseUint(key[i+1:], 10, 64)\n    return err == nil\n}","tryCatchPattern":"if err := gc(); err != nil {\n    if strings.Contains(err.Error(), \"fail to parse size\") {\n        logger.Warnf(\"skipping malformed pending slice: %v\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Keep the Redis keyspace exclusive to JuiceFS.","Avoid manual key manipulation with redis-cli.","Run GC after upgrades, not during them.","Back up Redis before bulk cleanup operations."],"tags":["go","redis","gc","key-format"],"backgroundTag":"invalid-identifier-format","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"}