{"record":{"id":"a2e41abd61c1636a","repo":"AlistGo/alist","slug":"invalid-label-id-s-v-a2e41a","errorCode":null,"errorMessage":"invalid label ID '%s': %v","messagePattern":"invalid label ID '(.+?)': (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"warning","filePath":"server/handles/label_file_binding.go","lineNumber":96,"sourceCode":"\t\t\t\"msg\": \"添加成功！\",\n\t\t})\n\t}\n}\n\nfunc DelLabelByFileName(c *gin.Context) {\n\tvar req DelLabelFileBinDingReq\n\tif err := c.ShouldBind(&req); err != nil {\n\t\tcommon.ErrorResp(c, err, 400)\n\t\treturn\n\t}\n\tuserObj, ok := c.Value(\"user\").(*model.User)\n\tif !ok {\n\t\tcommon.ErrorStrResp(c, \"user invalid\", 401)\n\t\treturn\n\t}\n\tlabelId, err := strconv.ParseUint(req.LabelId, 10, 64)\n\tif err != nil {\n\t\tcommon.ErrorResp(c, fmt.Errorf(\"invalid label ID '%s': %v\", req.LabelId, err), 500, true)\n\t\treturn\n\t}\n\tif err = db.DelLabelFileBinDingById(uint(labelId), userObj.ID, req.FileName); err != nil {\n\t\tcommon.ErrorResp(c, err, 500, true)\n\t\treturn\n\t}\n\tcommon.SuccessResp(c)\n}\n\nfunc GetFileByLabel(c *gin.Context) {\n\tlabelId := c.Query(\"label_id\")\n\tif labelId == \"\" {\n\t\tcommon.ErrorResp(c, errors.New(\"file_name must not empty\"), 400)\n\t\treturn\n\t}\n\tuserObj, ok := c.Value(\"user\").(*model.User)\n\tif !ok {\n\t\tcommon.ErrorStrResp(c, \"user invalid\", 401)","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/server/handles/label_file_binding.go#L78-L114","documentation":"HTTP handler DelLabelFileBinding binds a JSON body whose LabelId field is a string, then parses it with strconv.ParseUint. A non-numeric, negative, or overflowing label ID fails the parse. Note the handler answers with HTTP 500 even though this is a client input error — a status-code quirk of this endpoint.","triggerScenarios":"POST to the label-file-binding delete endpoint with \"label_id\": \"abc\", \"label_id\": null-derived \"\" or a signed/oversized value in the body.","commonSituations":"Client sending the numeric label ID as a JSON number (bound to string it may become garbage), sending the label name, or an empty string after a UI bug drops the field.","solutions":["Send label_id as a string of decimal digits (e.g. \"42\") matching an existing label ID","Validate client-side before POST: /^[0-9]+$/ and <= 2^64-1","Fetch valid IDs first via the label list endpoint and use one of those","Treat an HTTP 500 with this message as a 400-class input problem — fix the payload, not the server"],"exampleFix":"// before\ncurl -X POST /api/fs/del_label_file_binding -d '{\"label_id\":\"abc\",\"file_name\":\"a.txt\"}'\n\n// after\ncurl -X POST /api/fs/del_label_file_binding -d '{\"label_id\":\"42\",\"file_name\":\"a.txt\"}'","handlingStrategy":"validation","validationCode":"if !regexp.MustCompile(`^[0-9]{1,20}$`).MatchString(req.LabelId) {\n    return errors.New(\"label_id must be a non-negative integer string\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Send label_id as a decimal digit string sourced from the label list API","Validate in the client before POSTing; the endpoint returns 500 not 400","Never send label names or empty strings"],"tags":["go","http","validation","labels","api"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}