AlistGo/alist · warning
invalid label ID '%s': %v
Error message
invalid label ID '%s': %v
What it means
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.
Source
Thrown at server/handles/label_file_binding.go:96
"msg": "添加成功!",
})
}
}
func DelLabelByFileName(c *gin.Context) {
var req DelLabelFileBinDingReq
if err := c.ShouldBind(&req); err != nil {
common.ErrorResp(c, err, 400)
return
}
userObj, ok := c.Value("user").(*model.User)
if !ok {
common.ErrorStrResp(c, "user invalid", 401)
return
}
labelId, err := strconv.ParseUint(req.LabelId, 10, 64)
if err != nil {
common.ErrorResp(c, fmt.Errorf("invalid label ID '%s': %v", req.LabelId, err), 500, true)
return
}
if err = db.DelLabelFileBinDingById(uint(labelId), userObj.ID, req.FileName); err != nil {
common.ErrorResp(c, err, 500, true)
return
}
common.SuccessResp(c)
}
func GetFileByLabel(c *gin.Context) {
labelId := c.Query("label_id")
if labelId == "" {
common.ErrorResp(c, errors.New("file_name must not empty"), 400)
return
}
userObj, ok := c.Value("user").(*model.User)
if !ok {
common.ErrorStrResp(c, "user invalid", 401)View on GitHub (pinned to 843d9dc814)
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
Example fix
// before
curl -X POST /api/fs/del_label_file_binding -d '{"label_id":"abc","file_name":"a.txt"}'
// after
curl -X POST /api/fs/del_label_file_binding -d '{"label_id":"42","file_name":"a.txt"}' Defensive patterns
Strategy: validation
Validate before calling
if !regexp.MustCompile(`^[0-9]{1,20}$`).MatchString(req.LabelId) {
return errors.New("label_id must be a non-negative integer string")
} Prevention
- 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
When it happens
Trigger: POST to the label-file-binding delete endpoint with "label_id": "abc", "label_id": null-derived "" or a signed/oversized value in the body.
Common situations: 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.
Related errors
- invalid label_id '%s': %v
- invalid response
- page can't < 1
- per_page can't < 1
- http request [%s] failure,status: %d response:%s
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/a2e41abd61c1636a.
Report an issue: GitHub.