juicedata/juicefs · error
invalid quota type %d
Error message
invalid quota type %d
What it means
doGetQuota validates the quota type before querying: it must be DirQuotaType, UserQuotaType, or GroupQuotaType. Any other qtype value immediately returns "invalid quota type %d" without touching the database.
Source
Thrown at pkg/meta/sql.go:4326
return errno(m.txn(func(s *xorm.Session) error {
if err := m.getNodesForUpdate(s, &node{Inode: inode}); err != nil {
return err
}
n, err := s.Delete(&xattr{Inode: inode, Name: name})
if err != nil {
return err
} else if n == 0 {
return ENOATTR
} else {
m.genLog(ctx, s, time.Now().UnixNano(), "REMOVEXATTR(%d,%s)", inode, logEncode2(name))
return nil
}
}))
}
func (m *dbMeta) doGetQuota(ctx Context, qtype uint32, key uint64) (*Quota, error) {
if qtype != DirQuotaType && qtype != UserQuotaType && qtype != GroupQuotaType {
return nil, errors.Errorf("invalid quota type %d", qtype)
}
var quota *Quota
err := m.simpleTxn(ctx, func(s *xorm.Session) error {
if qtype == DirQuotaType {
q := &dirQuota{Inode: Ino(key)}
ok, e := s.Get(q)
if e == nil && ok {
quota = &Quota{
MaxSpace: q.MaxSpace,
MaxInodes: q.MaxInodes,
UsedSpace: q.UsedSpace,
UsedInodes: q.UsedInodes}
}
return e
} else {
q := &userGroupQuota{Qtype: qtype, Qkey: key}
ok, e := s.MustCols("qkey").Get(q)View on GitHub (pinned to c9a67b23e8)
Solutions
- Fix the caller to pass DirQuotaType, UserQuotaType, or GroupQuotaType
- Check client/JuiceFS version compatibility; upgrade both client and metadata format consistently
- Log/inspect the reported %d value to identify where the bad qtype originates
Example fix
// before quota, err := m.doGetQuota(ctx, 7, key) // after quota, err := m.doGetQuota(ctx, meta.DirQuotaType, key)
Defensive patterns
Strategy: validation
Validate before calling
if qtype != DirQuotaType && qtype != UserQuotaType && qtype != GroupQuotaType {
return fmt.Errorf("unsupported quota type %d", qtype)
} Type guard
func validQuotaType(q uint32) bool {
return q == DirQuotaType || q == UserQuotaType || q == GroupQuotaType
} Try / catch
if err != nil && strings.Contains(err.Error(), "invalid quota type") {
// fix the caller to use a defined quota type constant
} Prevention
- Always use the exported quota type constants, never raw numbers
- Keep client versions consistent in mixed clusters
- Validate quota type input in tooling before calling the meta API
When it happens
Trigger: Calling the quota lookup path (GetQuota / internal quota API) with a qtype constant outside {0 DirQuota, 1 UserQuota, 2 GroupQuota} — e.g. a corrupted/unknown value decoded from config or an older/newer client passing an unsupported quota type.
Common situations: Custom tooling calling the meta API with a wrong quota-type constant; version mismatch where a newer client introduced a quota type the SQL engine does not know; memory corruption or bad deserialization of qtype.
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
- --tier should be between 0 and 3
- --days should be at least 1
- illegal value for parameter 'ranger-service': " + serviceNam
- No sources given
- Source file " + normalizePath(src) + " is no
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/1c4be002a1f4049a.
Report an issue: GitHub.