AlistGo/alist · error

create offline task failed: empty task id

Error message

create offline task failed: empty task id

What it means

After POST /cloudcollection/v1/create_task answered with a success message, resp.Data.TaskID trimmed to empty. The offline task was not actually created server-side (or the response lost the id), so the driver refuses to return a phantom OfflineTask that later polling (OfflineList by task id) could never find.

Source

Thrown at drivers/guangyapan/offline.go:77

	body := map[string]any{
		"url":      taskURL,
		"parentId": parentID,
		"newName":  name,
	}
	if indexes := resolved.fileIndexes(); len(indexes) > 0 {
		body["fileIndexes"] = indexes
	}

	var resp offlineCreateResp
	if err := d.postAPI(ctx, "/cloudcollection/v1/create_task", body, &resp); err != nil {
		return nil, err
	}
	if !isSuccessMsg(resp.Msg) {
		return nil, fmt.Errorf("create offline task failed: %s", strings.TrimSpace(resp.Msg))
	}
	taskID := strings.TrimSpace(resp.Data.TaskID)
	if taskID == "" {
		return nil, errors.New("create offline task failed: empty task id")
	}
	return &OfflineTask{
		TaskID:   taskID,
		FileName: name,
		Res:      taskURL,
	}, nil
}

func (d *GuangYaPan) OfflineList(ctx context.Context, taskIDs []string, statuses []int, cursor string, pageSize int) ([]OfflineTask, error) {
	if err := d.ensureAccessToken(ctx); err != nil {
		return nil, err
	}
	body := map[string]any{}
	if len(taskIDs) > 0 {
		body["taskIds"] = taskIDs
	}
	if len(statuses) > 0 {
		body["status"] = statuses

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Log the full create_task response (code + body) to see why taskId is missing
  2. Validate/normalize the URL via ResolveOfflineResource first and surface its error instead
  3. Check the account's offline-task quota in the GuangYaPan web UI
  4. If the field was renamed server-side, update offlineCreateResp in types.go
Defensive patterns

Strategy: validation

Validate before calling

resolve, err := d.ResolveOfflineResource(ctx, taskURL)
if err != nil { return nil, err } // reject bad URLs before create_task
if strings.TrimSpace(resolve.TaskID) == "" && strings.TrimSpace(resolve.Name) == "" {
	return nil, errors.New("offline resource could not be resolved; refusing to create task")
}

Try / catch

task, err := d.createOfflineTask(ctx, ...)
if err != nil && strings.Contains(err.Error(), "empty task id") {
	return nil, fmt.Errorf("provider did not accept the offline URL: %w", err)
}

Prevention

When it happens

Trigger: create_task replies success-shaped JSON with data.taskId absent/blank — e.g. malformed magnet/ed2k URL the backend 'accepted' but did not enqueue, response schema drift, or a proxy stripping the data object.

Common situations: User pasted an unsupported or corrupted offline URL; provider changed taskId field name; account offline-task quota exhausted returns success body without a task.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/3cdecafd816b2ddd. Report an issue: GitHub.