[GH-ISSUE #468] [FEATURE REQUEST] Expose taskID when occurring Duplicated Error #215

Closed
opened 2026-03-02 05:19:41 +03:00 by kerem · 2 comments
Owner

Originally created by @linhbkhn95 on GitHub (May 17, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/468

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.

  • Currently, asynq only common error Duplicated TaskID when the created task is duplicated. So, If we use uniqueID via generating like blockNumber then we difficult to detect taskID which is duplicate.

Describe the solution you'd like
Currently, asynq uses error const as like below

// ErrTaskIDConflict indicates that the given task could not be enqueued since its task ID already exists.
//
// ErrTaskIDConflict error only applies to tasks enqueued with a TaskID option.
var ErrTaskIDConflict = errors.New("task ID conflicts with another task")

I think we can use error struct to catching taskID.

// ErrTaskIdConflict indicates that another task with the same task ID already exist.
type TaskIDConflictError struct {
	id string
}

func NewTaskIDConflictError(id string) error {
	return TaskIDConflictError{
		id: id,
	}
}

func (t TaskIDConflictError) Error() string {
	return fmt.Sprintf("task id conflicts with another task at taskID=%s", t.id)
}
Originally created by @linhbkhn95 on GitHub (May 17, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/468 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** - Currently, `asynq` only common error `Duplicated TaskID` when the created task is duplicated. So, If we use uniqueID via generating like `blockNumber` then we difficult to detect taskID which is duplicate. **Describe the solution you'd like** Currently,` asynq` uses error const as like below ``` // ErrTaskIDConflict indicates that the given task could not be enqueued since its task ID already exists. // // ErrTaskIDConflict error only applies to tasks enqueued with a TaskID option. var ErrTaskIDConflict = errors.New("task ID conflicts with another task") ``` I think we can use error struct to catching taskID. ``` // ErrTaskIdConflict indicates that another task with the same task ID already exist. type TaskIDConflictError struct { id string } func NewTaskIDConflictError(id string) error { return TaskIDConflictError{ id: id, } } func (t TaskIDConflictError) Error() string { return fmt.Sprintf("task id conflicts with another task at taskID=%s", t.id) }
kerem 2026-03-02 05:19:41 +03:00
Author
Owner

@hibiken commented on GitHub (May 18, 2022):

@linhbkhn95 thank you for creating an issue.

If you are getting ErrTaskIDConflict error, you are providing a custom ID using TaskID option. IMO it's redundant to include the ID in the error message, since user just called Enqueue with the ID.

<!-- gh-comment-id:1129532090 --> @hibiken commented on GitHub (May 18, 2022): @linhbkhn95 thank you for creating an issue. If you are getting `ErrTaskIDConflict` error, you are providing a custom ID using `TaskID` option. IMO it's redundant to include the ID in the error message, since user just called `Enqueue` with the ID.
Author
Owner

@linhbkhn95 commented on GitHub (May 18, 2022):

I think, almost case is duplicated ID from using a custom ID, So wrapping the ID into an error will provide insight to the user. Moreover, If users don't use a custom ID, sometimes, they use an ID generated for tracing. So, display ID duplicated is useful.

<!-- gh-comment-id:1129536027 --> @linhbkhn95 commented on GitHub (May 18, 2022): I think, almost case is duplicated ID from using a custom ID, So wrapping the ID into an error will provide insight to the user. Moreover, If users don't use a custom ID, sometimes, they use an ID generated for tracing. So, display ID duplicated is useful.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#215
No description provided.