AlistGo/alist · warning

invalid label ID '%s': %v

Error message

invalid label ID '%s': %v

What it means

Thrown while parsing a comma-separated list of label IDs (label_file_binding). The string is normalized (CJK punctuation ,、; converted to commas), split on ',', trimmed, and each non-empty token must parse as an unsigned 64-bit base-10 integer. Any token that is not a pure non-negative number makes strconv.ParseUint fail and this error is returned with the offending token.

Source

Thrown at internal/op/label_file_binding.go:190

	if len(req.LabelIDs) > 0 {
		return req.LabelIDs, nil
	}
	s := strings.TrimSpace(req.LabelIds)
	if s == "" {
		return nil, nil
	}
	replacer := strings.NewReplacer(",", ",", "、", ",", ";", ",", ";", ",")
	s = replacer.Replace(s)
	parts := strings.Split(s, ",")
	ids := make([]uint64, 0, len(parts))
	for _, p := range parts {
		p = strings.TrimSpace(p)
		if p == "" {
			continue
		}
		id, err := strconv.ParseUint(p, 10, 64)
		if err != nil {
			return nil, fmt.Errorf("invalid label ID '%s': %v", p, err)
		}
		ids = append(ids, id)
	}
	return ids, nil
}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Pre-validate each token with the same rules (strip CJK separators, trim, regexp ^[0-9]+$) before calling the API
  2. Fix the caller to send only numeric, comma-separated label IDs
  3. If a token is non-numeric, drop it or surface a field-level validation message to the user instead of failing the whole request
  4. Check for uint64 overflow when IDs come from another system (e.g. snowflake IDs from a 3rd-party app)

Example fix

// before
ids := parseLabelIDs("1,abc,3") // error: invalid label ID 'abc'

// after
re := regexp.MustCompile(`^[0-9]+$`)
var clean []string
for _, p := range strings.Split(strings.NewReplacer(",", ",", ";", ",").Replace(raw), ",") {
    p = strings.TrimSpace(p)
    if re.MatchString(p) {
        clean = append(clean, p)
    }
}
ids := parseLabelIDs(strings.Join(clean, ","))
Defensive patterns

Strategy: validation

Validate before calling

func validLabelIDList(s string) bool {
    s = strings.NewReplacer(",", ",", "、", ",", ";", ",").Replace(s)
    for _, p := range strings.Split(s, ",") {
        p = strings.TrimSpace(p)
        if p == "" {
            continue
        }
        if _, err := strconv.ParseUint(p, 10, 64); err != nil {
            return false
        }
    }
    return true
}

Prevention

When it happens

Trigger: Calling the internal label-binding parse function with a string like "1,abc,3", a negative number "-1", a float "1.5", a number with whitespace inside like "1 2", or an ID exceeding uint64 range ( > 18446744073709551615).

Common situations: Frontend sending label IDs joined with an unsupported separator (e.g. '-' or '|'), user-typed input containing stray characters, or a stale client sending label names instead of numeric IDs after an API change.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/619e17693f1f7de4. Report an issue: GitHub.