{"record":{"id":"619e17693f1f7de4","repo":"AlistGo/alist","slug":"invalid-label-id-s-v","errorCode":null,"errorMessage":"invalid label ID '%s': %v","messagePattern":"invalid label ID '(.+?)': (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/op/label_file_binding.go","lineNumber":190,"sourceCode":"\tif len(req.LabelIDs) > 0 {\n\t\treturn req.LabelIDs, nil\n\t}\n\ts := strings.TrimSpace(req.LabelIds)\n\tif s == \"\" {\n\t\treturn nil, nil\n\t}\n\treplacer := strings.NewReplacer(\"，\", \",\", \"、\", \",\", \"；\", \",\", \";\", \",\")\n\ts = replacer.Replace(s)\n\tparts := strings.Split(s, \",\")\n\tids := make([]uint64, 0, len(parts))\n\tfor _, p := range parts {\n\t\tp = strings.TrimSpace(p)\n\t\tif p == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tid, err := strconv.ParseUint(p, 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid label ID '%s': %v\", p, err)\n\t\t}\n\t\tids = append(ids, id)\n\t}\n\treturn ids, nil\n}\n","sourceCodeStart":172,"sourceCodeEnd":196,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/internal/op/label_file_binding.go#L172-L196","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Pre-validate each token with the same rules (strip CJK separators, trim, regexp ^[0-9]+$) before calling the API","Fix the caller to send only numeric, comma-separated label IDs","If a token is non-numeric, drop it or surface a field-level validation message to the user instead of failing the whole request","Check for uint64 overflow when IDs come from another system (e.g. snowflake IDs from a 3rd-party app)"],"exampleFix":"// before\nids := parseLabelIDs(\"1,abc,3\") // error: invalid label ID 'abc'\n\n// after\nre := regexp.MustCompile(`^[0-9]+$`)\nvar clean []string\nfor _, p := range strings.Split(strings.NewReplacer(\"，\", \",\", \";\", \",\").Replace(raw), \",\") {\n    p = strings.TrimSpace(p)\n    if re.MatchString(p) {\n        clean = append(clean, p)\n    }\n}\nids := parseLabelIDs(strings.Join(clean, \",\"))","handlingStrategy":"validation","validationCode":"func validLabelIDList(s string) bool {\n    s = strings.NewReplacer(\"，\", \",\", \"、\", \",\", \"；\", \",\").Replace(s)\n    for _, p := range strings.Split(s, \",\") {\n        p = strings.TrimSpace(p)\n        if p == \"\" {\n            continue\n        }\n        if _, err := strconv.ParseUint(p, 10, 64); err != nil {\n            return false\n        }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize separators and trim tokens on the client before composing the ID list","Bind UI label pickers to numeric IDs only, never free-text","Return field-level errors instead of failing the whole binding operation"],"tags":["go","validation","labels","input-parsing"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}