juicedata/juicefs · error

unknown quota type: %d

Error message

unknown quota type: %d

What it means

getQuotaKeys maps a quota type constant (dir, group, etc.) to its Redis key set. Passing a qtype that the code does not recognize hits the default branch and returns this error instead of operating on the wrong keys.

Source

Thrown at pkg/meta/redis.go:4408

		return &quotaKeys{
			quotaKey:      m.dirQuotaKey(),
			usedSpaceKey:  m.dirQuotaUsedSpaceKey(),
			usedInodesKey: m.dirQuotaUsedInodesKey(),
		}, nil
	case UserQuotaType:
		return &quotaKeys{
			quotaKey:      m.userQuotaKey(),
			usedSpaceKey:  m.userQuotaUsedSpaceKey(),
			usedInodesKey: m.userQuotaUsedInodesKey(),
		}, nil
	case GroupQuotaType:
		return &quotaKeys{
			quotaKey:      m.groupQuotaKey(),
			usedSpaceKey:  m.groupQuotaUsedSpaceKey(),
			usedInodesKey: m.groupQuotaUsedInodesKey(),
		}, nil
	default:
		return nil, fmt.Errorf("unknown quota type: %d", qtype)
	}
}

func (m *redisMeta) doGetQuota(ctx Context, qtype uint32, key uint64) (*Quota, error) {
	config, err := m.getQuotaKeys(qtype)
	if err != nil {
		return nil, err
	}

	field := strconv.FormatUint(key, 10)
	cmds, err := m.rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
		pipe.HGet(ctx, config.quotaKey, field)
		pipe.HGet(ctx, config.usedSpaceKey, field)
		pipe.HGet(ctx, config.usedInodesKey, field)
		return nil
	})
	if err == redis.Nil {
		return nil, nil

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Upgrade the JuiceFS client/binary to a version that supports the quota type in question.
  2. Check the caller passing qtype — it should come from the defined quota type constants, not raw user input.
  3. List existing quotas (`juicefs quota <meta-url>`) to see which quota types exist and remove unsupported ones with a matching-version client.
  4. Ensure all mounted clients run a compatible JuiceFS version before enabling newer quota features.
Defensive patterns

Strategy: try-catch

Validate before calling

// only pass quota types your binary supports; enumerate first
quotas, _ := cli.ListQuota(ctx)
for _, q := range quotas { if !supportedQuotaType(q.Type) { fmt.Printf("quota type %d unsupported by this client — upgrade juicefs\n", q.Type) } }

Try / catch

q, err := meta.GetQuota(ctx, qtype, key)
if err != nil && strings.Contains(err.Error(), "unknown quota type") {
    return fmt.Errorf("client too old for quota type %d; upgrade juicefs: %w", qtype, err)
}

Prevention

When it happens

Trigger: Calling quota APIs (GetQuota/SetQuota/DelQuota and their internal doGetQuota/doSetQuota wrappers) with a qtype value outside the supported set — typically from a newer client writing quota records that an older binary doesn't understand, or an internal caller bug.

Common situations: Mixed-version clusters where a newer client set directory/group quotas and an older client's maintenance code reads them; custom tooling invoking internal meta APIs with wrong constants.

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


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/4f846ef88eda8991. Report an issue: GitHub.