{"record":{"id":"d9b5154c93b3308e","repo":"juicedata/juicefs","slug":"invalid-quota-value-v-d9b515","errorCode":null,"errorMessage":"invalid quota value: %v","messagePattern":"invalid quota value: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/tkv.go","lineNumber":3504,"sourceCode":"\t\treturn nil, fmt.Errorf(\"invalid quota type: %d\", qtype)\n\t}\n}\n\nfunc (m *kvMeta) doGetQuota(ctx Context, qtype uint32, key uint64) (*Quota, error) {\n\tquotaKey, err := m.getQuotaKey(qtype, key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf, err := m.get(quotaKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif buf == nil {\n\t\treturn nil, nil\n\t}\n\tif len(buf) != 32 {\n\t\treturn nil, fmt.Errorf(\"invalid quota value: %v\", buf)\n\t}\n\n\treturn m.parseQuota(buf), nil\n}\n\nfunc (m *kvMeta) doSetQuota(ctx Context, qtype uint32, key uint64, quota *Quota) (bool, error) {\n\tquotaKey, err := m.getQuotaKey(qtype, key)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tvar created bool\n\terr = m.txn(ctx, func(tx *kvTxn) error {\n\t\tbuf := tx.get(quotaKey)\n\t\tvar origin *Quota\n\t\tvar exists bool\n\t\tif len(buf) == 32 {\n\t\t\torigin = m.parseQuota(buf)","sourceCodeStart":3486,"sourceCodeEnd":3522,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/tkv.go#L3486-L3522","documentation":"doGetQuota reads a quota record from the KV store and requires exactly 32 bytes (four packed big-endian int64s: MaxInodes, MaxSpace, UsedInodes, UsedSpace). Any other non-nil length means the stored value is corrupt or written by an incompatible format, so parsing is refused.","triggerScenarios":"Reading a user/group/dir quota ('QU'/'QG'/'QD' prefixed key) whose value length is not 32 bytes — e.g. after a bad restore, manual edit, or cross-version record format change.","commonSituations":"Metadata restored from a dump of a different JuiceFS version; hand-edited KV records; partial writes from a crashed client (if the store lacks transactional guarantees).","solutions":["Restore quota records from a consistent 'juicefs dump' backup","Inspect the offending quota key's value length in the KV store and re-set the quota with juicefs quota to overwrite the corrupt value","Ensure all clients run a JuiceFS version that writes the same 32-byte quota encoding","Delete the corrupt quota key and recreate the quota with 'juicefs quota set'"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check quota reads succeed before relying on them\nq, err := meta.GetQuota(ctx, qtype, key)\nif err != nil && strings.Contains(err.Error(), \"invalid quota value\") {\n\t// restore or re-set the quota\n}","typeGuard":null,"tryCatchPattern":"if _, err := doGetQuota(ctx, qtype, key); err != nil {\n\tif strings.Contains(err.Error(), \"invalid quota value\") {\n\t\t// delete the corrupt key and re-set quota via CLI\n\t}\n}","preventionTips":["Restore metadata only from complete dumps of the same JuiceFS version","Never manually edit quota records in the KV store","Re-set quotas after any partial restore","Monitor for failed/partial writes if the KV store lacks transactions"],"tags":["quota","corruption","kv-store"],"backgroundTag":"schema-validation-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"}