juicedata/juicefs · error
invalid quota command: %d
Error message
invalid quota command: %d
What it means
HandleQuota received a quota sub-command value it does not recognize. Valid commands are set/get/del/list/check; anything else falls through to the default branch and reports the numeric command value.
Source
Thrown at pkg/meta/quota.go:620
if err != nil {
return fmt.Errorf("parse quota key %q: %s", qkey, err)
}
key = id
}
switch cmd {
case QuotaSet:
return m.handleQuotaSet(ctx, qtype, key, dpath, quotas, strict)
case QuotaGet:
return m.handleQuotaGet(ctx, qtype, key, dpath, quotas)
case QuotaDel:
return m.en.doDelQuota(ctx, qtype, key)
case QuotaList:
return m.handleQuotaList(ctx, qtype, key, quotas)
case QuotaCheck:
return m.handleQuotaCheck(ctx, qtype, key, dpath, strict, repair, quotas)
default:
return fmt.Errorf("invalid quota command: %d", cmd)
}
}
func (m *baseMeta) handleQuotaSet(ctx Context, qtype uint32, key uint64, dpath string, quotas map[string]*Quota, strict bool) error {
format := m.getFormat()
var quota *Quota
var scan bool = false
switch qtype {
case DirQuotaType:
if !format.DirStats {
format.DirStats = true
err := m.en.doInit(format, false)
if err != nil {
logger.Warnf("init dir stats: %s", err)
}
}
quota = quotas[dpath]
case UserQuotaType:View on GitHub (pinned to c9a67b23e8)
Solutions
- Use one of the supported commands: set, get, del, list, check.
- Rebuild/redeploy so the caller and the juicefs library are the same version.
- If adding a new command, extend the switch in HandleQuota and the CLI flag validation together.
Example fix
// before err = m.HandleQuota(ctx, DirQuotaType, 999 /*unknown cmd*/, "/data", ...) // after err = m.HandleQuota(ctx, DirQuotaType, QuotaSet, "/data", ...)
Defensive patterns
Strategy: validation
Validate before calling
case "$CMD" in set|get|del|list|check) ;; *) echo "unsupported quota command: $CMD"; exit 1;; esac
Prevention
- Restrict inputs to the documented set/get/del/list/check commands.
- Keep caller and library versions aligned when driving the meta API programmatically.
- Use the CLI flags rather than calling internal APIs directly.
When it happens
Trigger: An internal caller or API consumer passes an undefined QuotaCmd value into HandleQuota (the CLI normally constrains choices, so this usually indicates a programmatic misuse or version mismatch between caller and library).
Common situations: Third-party tooling or scripts driving the meta API with a hand-rolled command constant; a binary built against mismatched juicefs library versions where a new command is sent to an older implementation.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- no quota for any trash directory
- Aborted.
- cannot disable dir stats when there are still %d dir quotas:
- resolve dir %s: %s
- parse quota key %q: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/078756dc5313165f.
Report an issue: GitHub.