{"record":{"id":"543dd3999d21874d","repo":"Tencent/WeKnora","slug":"unsupported-runtime-task-state-q","errorCode":null,"errorMessage":"unsupported runtime task state %q","messagePattern":"unsupported runtime task state %q","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/router/task_inspector.go","lineNumber":547,"sourceCode":"\t}\n}\n\n// ListRuntimeTasks returns one cursor page in state-appropriate time order:\n// newest first for pending/active/archived/completed, and next-to-run first\n// for scheduled/retry. Only allow-listed routing metadata is projected from\n// payloads so the dashboard never exposes document content or secrets.\nfunc (a *asynqTaskInspector) ListRuntimeTasks(\n\tctx context.Context,\n\tqueue string,\n\tstate types.RuntimeTaskState,\n\tcursor string,\n\tpageSize int,\n) (types.RuntimeTaskPage, bool, error) {\n\tif a == nil || a.inspector == nil || a.redis == nil {\n\t\treturn types.RuntimeTaskPage{}, false, nil\n\t}\n\tif !state.Valid() {\n\t\treturn types.RuntimeTaskPage{}, true, fmt.Errorf(\"unsupported runtime task state %q\", state)\n\t}\n\tif pageSize < 1 {\n\t\tpageSize = 20\n\t}\n\tif pageSize > 100 {\n\t\tpageSize = 100\n\t}\n\tanchors, err := decodeRuntimeTaskCursor(cursor, queue, state)\n\tif err != nil {\n\t\treturn types.RuntimeTaskPage{}, true, err\n\t}\n\tworkers := map[string]runtimeWorkerMetadata{}\n\tif state == types.RuntimeTaskActive {\n\t\tworkers = a.activeWorkerMetadata()\n\t}\n\tresult := make([]types.RuntimeTaskInfo, 0, pageSize)\n\thasMore := false\n","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/router/task_inspector.go#L529-L565","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use one of the exact state values accepted by types' runtime task state enum (call state.Valid()/the documented set).","Validate/normalize the state parameter in the client before calling.","Check for enum renames if this worked before a version upgrade."],"exampleFix":"// before\npage, _, err := ListRuntimeTasks(ctx, \"pendng\", cursor, 20) // typo\n// after\npage, _, err := ListRuntimeTasks(ctx, \"pending\", cursor, 20)","handlingStrategy":"type-guard","validationCode":"if !isValidRuntimeTaskState(stateParam) { // reject or default before calling\n}","typeGuard":"func validRuntimeTaskState(s string) (types.RuntimeTaskState, bool) {\n    st := types.RuntimeTaskState(s)\n    return st, st.Valid()\n}","tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"unsupported runtime task state\") {\n        // surface valid state options to the user / clear stale filter\n    }\n}","preventionTips":["Derive filter dropdown options from the same enum the server validates.","Normalize case/whitespace on the state parameter.","Re-check enum values after upgrading the server version."],"tags":["validation","api","task-inspector"],"backgroundTag":"invalid-enum-value","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}