Tencent/WeKnora · error

unsupported runtime task state

Error message

unsupported runtime task state %q

What it means

ListRuntimeTasks in internal/router/task_inspector.go:547 returns this error when the requested runtime task state string does not match any valid state via state.Valid(). Unlike pure filters, an unrecognized state is treated as a caller mistake rather than an empty result, so it fails fast with the offending value quoted.

Solutions

  1. Use one of the exact state values accepted by types' runtime task state enum (call state.Valid()/the documented set).
  2. Validate/normalize the state parameter in the client before calling.
  3. Check for enum renames if this worked before a version upgrade.

Example fix

// before
page, _, err := ListRuntimeTasks(ctx, "pendng", cursor, 20) // typo
// after
page, _, err := ListRuntimeTasks(ctx, "pending", cursor, 20)
Defensive patterns

Strategy: type-guard

Validate before calling

if !isValidRuntimeTaskState(stateParam) { // reject or default before calling
}

Type guard

func validRuntimeTaskState(s string) (types.RuntimeTaskState, bool) {
    st := types.RuntimeTaskState(s)
    return st, st.Valid()
}

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "unsupported runtime task state") {
        // surface valid state options to the user / clear stale filter
    }
}

Prevention

When it happens

Trigger: Calling ListRuntimeTasks (admin/inspector API) with a state value that isn't a defined runtime task state — e.g. a typo like "pendng", renamed state constant, or arbitrary user-supplied filter string passed through unvalidated.

Common situations: Dashboard filter built from stale UI options after state enum renames; scripts passing human words like "running now"; case mismatches between caller and enum values.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/543dd3999d21874d. Report an issue: GitHub.

Appendix: source

Thrown at internal/router/task_inspector.go:547

	}
}

// ListRuntimeTasks returns one cursor page in state-appropriate time order:
// newest first for pending/active/archived/completed, and next-to-run first
// for scheduled/retry. Only allow-listed routing metadata is projected from
// payloads so the dashboard never exposes document content or secrets.
func (a *asynqTaskInspector) ListRuntimeTasks(
	ctx context.Context,
	queue string,
	state types.RuntimeTaskState,
	cursor string,
	pageSize int,
) (types.RuntimeTaskPage, bool, error) {
	if a == nil || a.inspector == nil || a.redis == nil {
		return types.RuntimeTaskPage{}, false, nil
	}
	if !state.Valid() {
		return types.RuntimeTaskPage{}, true, fmt.Errorf("unsupported runtime task state %q", state)
	}
	if pageSize < 1 {
		pageSize = 20
	}
	if pageSize > 100 {
		pageSize = 100
	}
	anchors, err := decodeRuntimeTaskCursor(cursor, queue, state)
	if err != nil {
		return types.RuntimeTaskPage{}, true, err
	}
	workers := map[string]runtimeWorkerMetadata{}
	if state == types.RuntimeTaskActive {
		workers = a.activeWorkerMetadata()
	}
	result := make([]types.RuntimeTaskInfo, 0, pageSize)
	hasMore := false

View on GitHub (pinned to 988cbb0330)