{"record":{"id":"bd6b6dfd178dcc9b","repo":"hibiken/asynq","slug":"unknown-type-t-value-v-in-error-call","errorCode":null,"errorMessage":"unknown type %T, value %v in error call","messagePattern":"unknown type %T, value (.+?) in error call","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/errors/errors.go","lineNumber":142,"sourceCode":"func E(args ...interface{}) error {\n\tif len(args) == 0 {\n\t\tpanic(\"call to errors.E with no arguments\")\n\t}\n\te := &Error{}\n\tfor _, arg := range args {\n\t\tswitch arg := arg.(type) {\n\t\tcase Op:\n\t\t\te.Op = arg\n\t\tcase Code:\n\t\t\te.Code = arg\n\t\tcase error:\n\t\t\te.Err = arg\n\t\tcase string:\n\t\t\te.Err = errors.New(arg)\n\t\tdefault:\n\t\t\t_, file, line, _ := runtime.Caller(1)\n\t\t\tlog.Printf(\"errors.E: bad call from %s:%d: %v\", file, line, args)\n\t\t\treturn fmt.Errorf(\"unknown type %T, value %v in error call\", arg, arg)\n\t\t}\n\t}\n\treturn e\n}\n\n// CanonicalCode returns the canonical code of the given error if one is present.\n// Otherwise it returns Unspecified.\nfunc CanonicalCode(err error) Code {\n\tif err == nil {\n\t\treturn Unspecified\n\t}\n\te, ok := err.(*Error)\n\tif !ok {\n\t\treturn Unspecified\n\t}\n\tif e.Code == Unspecified {\n\t\treturn CanonicalCode(e.Err)\n\t}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/internal/errors/errors.go#L124-L160","documentation":"errors.E builds a structured *errors.Error from variadic arguments (code, string, error). When an argument's type matches none of the accepted kinds, the function logs the bad call site via runtime.Caller and returns this sentinel error instead of a structured one. It signals a programming mistake: E was called with an unsupported argument type.","triggerScenarios":"Calling errors.E with any argument other than a Code, a string, or an error value — e.g. errors.E(42), errors.E(someStruct), errors.E(nil), or errors.E(errors.Internal, 123, \"msg\").","commonSituations":"Refactors where an int constant is passed instead of errors.Code; passing a custom error wrapper type that is not an `error`; copy-paste from other error libraries where E accepts arbitrary values; passing nil interface as the error argument.","solutions":["Inspect the log line 'errors.E: bad call from <file>:<line>' to find the exact call site, then fix the argument types there.","Convert unsupported values: numbers/structs into fmt.Errorf(\"...\", v), and ensure custom error types implement the `error` interface.","Only pass errors.Code values (e.g. errors.Internal), strings, or error values to E."],"exampleFix":"// before\nreturn errors.E(errors.Internal, http.StatusText(code), resp.StatusCode)\n// after\nreturn errors.E(errors.Internal, fmt.Errorf(\"unexpected status: %d\", resp.StatusCode))","handlingStrategy":"type-guard","validationCode":"// ensure only accepted argument types are passed\ncode := errors.Internal\nvar errArg error = fmt.Errorf(\"status %d\", resp.StatusCode)\nreturn errors.E(code, errArg)","typeGuard":"func isValidEArg(arg interface{}) bool {\n    switch arg.(type) {\n    case nil, string, error:\n        return true\n    }\n    if _, ok := arg.(errors.Code); ok { return true }\n    return false\n}","tryCatchPattern":"err := doWork()\nvar e *errors.Error\nif errors.As(err, &e) {\n    // structured error\n} else if strings.Contains(err.Error(), \"unknown type\") {\n    log.Fatalf(\"bad errors.E call: %v\", err) // fix call site\n}","preventionTips":["Grep for errors.E calls passing non-string, non-error, non-Code arguments during code review.","Convert numeric/struct context with fmt.Errorf before passing to E.","Watch the 'errors.E: bad call from <file>:<line>' log output in development to catch misuse early."],"tags":["go","error-handling","invalid-argument","api-misuse"],"backgroundTag":"invalid-argument-value","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"}