{"record":{"id":"1ed02ee84996ad63","repo":"hibiken/asynq","slug":"unexpected-return-value-from-script-v","errorCode":null,"errorMessage":"unexpected return value from script: %v","messagePattern":"unexpected return value from script: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/rdb/inspect.go","lineNumber":1422,"sourceCode":"\tkeys := []string{\n\t\tsrc,\n\t\tdst,\n\t}\n\tnow := r.clock.Now()\n\targv := []interface{}{\n\t\tnow.Unix(),\n\t\tnow.AddDate(0, 0, -archivedExpirationInDays).Unix(),\n\t\tmaxArchiveSize,\n\t\tbase.TaskKeyPrefix(qname),\n\t\tqname,\n\t}\n\tres, err := archiveAllCmd.Run(context.Background(), r.client, keys, argv...).Result()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tn, ok := res.(int64)\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unexpected return value from script: %v\", res)\n\t}\n\tif n == -1 {\n\t\treturn 0, &errors.QueueNotFoundError{Queue: qname}\n\t}\n\treturn n, nil\n}\n\n// Input:\n// KEYS[1] -> asynq:{<qname>}:t:<task_id>\n// --\n// ARGV[1] -> task message data\n//\n// Output:\n// Numeric code indicating the status:\n// Returns 1 if task is successfully updated.\n// Returns 0 if task is not found.\n// Returns -1 if task is not in scheduled state.\nvar updateTaskPayloadCmd = redis.NewScript(`","sourceCodeStart":1404,"sourceCodeEnd":1440,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/internal/rdb/inspect.go#L1404-L1440","documentation":"Returned by RDB archive-all operations when the archiveAllCmd Lua script yields a value that is not int64. The script is expected to return an integer count of archived tasks (or -1 for a missing queue); any other reply type fails this assertion. It signals an unexpected Redis reply rather than an application-level problem.","triggerScenarios":"Calling ArchiveAllPendingTasks (or similar archive-all APIs) where the Lua script's Result() is a string, redis.Message, or nil instead of int64 — typically due to a non-standard Redis server or altered reply handling.","commonSituations":"Redis proxies/clusters that reshape EVAL replies; custom Redis forks; running an asynq build with mismatched internal scripts.","solutions":["Confirm standard Redis is used and returns integer replies from EVAL","Verify internal Lua scripts match the asynq release","Inspect the logged value to identify the actual returned type","Upgrade asynq and go-redis to compatible versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"paused, err := inspector.ArchivedSize(q)\n_ = paused // verify Redis connectivity/reply types before bulk archive ops","typeGuard":"func isInt64(res interface{}) bool {\n    _, ok := res.(int64)\n    return ok\n}","tryCatchPattern":"n, err := inspector.ArchiveAllPendingTasks(q)\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected return value from script\") {\n        // log the reply, escalate to standard-Redis check\n    }\n    return err\n}","preventionTips":["Avoid Redis proxies that reshape Lua replies","Keep internal Lua scripts unmodified","Test archive ops against the real cluster","Monitor for repeated occurrences indicating server drift"],"tags":["redis","lua","type-mismatch"],"backgroundTag":"unexpected-response-shape","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"}