{"record":{"id":"a77db1a9ea660a55","repo":"hibiken/asynq","slug":"asynq-v","errorCode":null,"errorMessage":"asynq: %v","messagePattern":"asynq: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"inspector.go","lineNumber":596,"sourceCode":"// and reports the number of tasks deleted.\nfunc (i *Inspector) DeleteAllAggregatingTasks(queue, group string) (int, error) {\n\tif err := base.ValidateQueueName(queue); err != nil {\n\t\treturn 0, err\n\t}\n\tn, err := i.rdb.DeleteAllAggregatingTasks(queue, group)\n\treturn int(n), err\n}\n\n// UpdateTaskPayload updates a task with the given id from the given queue with given payload.\n// The task needs to be in scheduled state,\n// otherwise UpdateTaskPayload will return an error.\n//\n// If a queue with the given name doesn't exist, it returns an error wrapping ErrQueueNotFound.\n// If a task with the given id doesn't exist in the queue, it returns an error wrapping ErrTaskNotFound.\n// If the task is not in scheduled state, it returns a non-nil error.\nfunc (i *Inspector) UpdateTaskPayload(queue, id string, payload []byte) error {\n\tif err := base.ValidateQueueName(queue); err != nil {\n\t\treturn fmt.Errorf(\"asynq: %v\", err)\n\t}\n\terr := i.rdb.UpdateTaskPayload(queue, id, payload)\n\tswitch {\n\tcase errors.IsQueueNotFound(err):\n\t\treturn fmt.Errorf(\"asynq: %w\", ErrQueueNotFound)\n\tcase errors.IsTaskNotFound(err):\n\t\treturn fmt.Errorf(\"asynq: %w\", ErrTaskNotFound)\n\tcase err != nil:\n\t\treturn fmt.Errorf(\"asynq: %v\", err)\n\t}\n\treturn nil\n\n}\n\n// DeleteTask deletes a task with the given id from the given queue.\n// The task needs to be in pending, scheduled, retry, or archived state,\n// otherwise DeleteTask will return an error.\n//","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/inspector.go#L578-L614","documentation":"UpdateTaskPayload rejects the queue name before touching Redis: base.ValidateQueueName returned an error, wrapped with 'asynq: %v'. Because %v is used (not %w), the validation error is not sentinel-wrappable; it is a plain formatted message. Queue names must be non-empty, alphanumeric-ish strings satisfying asynq's naming rules (no spaces or special characters).","triggerScenarios":"Calling Inspector.UpdateTaskPayload(queue, id, payload) where queue contains invalid characters (spaces, ':', uppercase per validation rules) or is empty, producing an ErrQueueName validation error.","commonSituations":"Building queue names from user input or route parameters without sanitizing; accidentally passing an ID as the first argument; swapping the queue and task-id arguments.","solutions":["Sanitize the queue name: letters/digits, no spaces or special characters, non-empty.","Check argument order — first arg is queue name, second is task id.","Reuse base.ValidateQueueName logic (or the asynq export) to validate the name before calling.","Log the exact queue string to spot hidden whitespace or wrong interpolation."],"exampleFix":"// before\nerr := insp.UpdateTaskPayload(\"email: high priority\", taskID, newPayload)\n// after\nqueue := \"email-high-priority\" // valid asynq queue name\nif err := insp.UpdateTaskPayload(queue, taskID, newPayload); err != nil {\n    log.Fatalf(\"update failed: %v\", err)\n}","handlingStrategy":"validation","validationCode":"func validQueueName(q string) bool {\n    return q != \"\" && !strings.ContainsAny(q, \" :/\\\\\")\n}\n// call only if validQueueName(queue)","typeGuard":"func sanitizeQueueName(q string) (string, bool) {\n    q = strings.TrimSpace(q)\n    if q == \"\" || !regexp.MustCompile(`^[a-zA-Z0-9_-]+$`).MatchString(q) {\n        return \"\", false\n    }\n    return q, true\n}","tryCatchPattern":null,"preventionTips":["Define queue names as package-level constants, never from raw user input.","Trim whitespace from config-sourced queue names at startup.","Keep argument order (queue, id) consistent by using a small wrapper function.","Sanitize any queue name derived from HTTP paths or job metadata."],"tags":["validation","queue-name","asynq"],"backgroundTag":"invalid-argument-value","analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}