{"record":{"id":"aec788faaae7b5b2","repo":"reactiveui/refit","slug":"sequence-contains-no-elements","errorCode":null,"errorMessage":"Sequence contains no elements","messagePattern":"Sequence contains no elements","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Refit.Reflection/RestMethodInfoInternal.cs","lineNumber":53,"sourceCode":"    /// <param name=\"clientPathPrefix\">The shared route prefix declared by the client interface's <see cref=\"PathPrefixAttribute\"/>, or null when none applies.</param>\n    /// <exception cref=\"InvalidOperationException\"><paramref name=\"methodInfo\"/> carries no <see cref=\"HttpMethodAttribute\"/>, so it declares no HTTP verb or path.</exception>\n    [RequiresUnreferencedCode(\"Building request metadata from reflected interface methods requires request object property metadata to be available at runtime.\")]\n    internal RestMethodInfoInternal(\n        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]\n        Type targetInterface,\n        MethodInfo methodInfo,\n        RefitSettings? refitSettings = null,\n        string? clientPathPrefix = null)\n    {\n        RefitSettings = refitSettings ?? new RefitSettings();\n        ArgumentExceptionHelper.ThrowIfNull(targetInterface);\n        ArgumentExceptionHelper.ThrowIfNull(methodInfo);\n        Type = targetInterface;\n        MethodInfo = methodInfo;\n        ClientPathPrefix = clientPathPrefix ?? string.Empty;\n\n        var hma = methodInfo.GetCustomAttribute<HttpMethodAttribute>(true)\n                  ?? throw new InvalidOperationException(\"Sequence contains no elements\");\n\n        HttpMethod = hma.Method;\n        RelativePath = CombineWithPathPrefix(ClientPathPrefix, hma.Path);\n\n        IsMultipart = methodInfo.GetCustomAttribute<MultipartAttribute>(true) is not null;\n\n        MultipartBoundary = GetMultipartBoundary(methodInfo, IsMultipart);\n\n        VerifyUrlPathIsSane(RelativePath, RefitSettings.UrlResolution);\n\n        HasReturnTypeAdapter = ReturnTypeAdapterResolver.TryResolveResultType(\n            methodInfo.ReturnType,\n            RefitSettings.ReturnTypeAdapters,\n            out var adapterResultType);\n        var (returnType, returnResultType, deserializedResultType) =\n            DetermineReturnTypeInfo(methodInfo, adapterResultType);\n        ReturnType = returnType;\n        ReturnResultType = returnResultType;","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/reactiveui/refit/blob/b455f65ecc4c97d092317e349cb775f9cfc6bcdf/src/Refit.Reflection/RestMethodInfoInternal.cs#L35-L71","documentation":"When building the RestMethodInfo for a single interface method, Refit requires a HttpMethodAttribute (Get/Post/Put/Patch/Delete/Head). If the method has none, the GetCustomAttribute call returns null and this 'Sequence contains no elements' InvalidOperationException is thrown. It mirrors error 5 but fires during per-method construction rather than name lookup.","triggerScenarios":"An interface method passed to RestMethodInfoInternal has no HTTP method attribute, e.g. a helper/property/getter that slipped into a Refit interface, or an inherited member without an attribute.","commonSituations":"Adding a non-HTTP helper method to a Refit interface; inheriting from a base interface that has plain members; forgetting the verb attribute on a new endpoint.","solutions":["Add an HTTP method attribute to every method on the Refit interface.","Move non-HTTP helper members out of the Refit interface into a separate class/interface."],"exampleFix":"// before\npublic interface IApi {\n    Task<List<Item>> GetAllAsync(); // no attribute\n}\n\n// after\npublic interface IApi {\n    [Get(\"/items\")] Task<List<Item>> GetAllAsync();\n}","handlingStrategy":"validation","validationCode":"static void AssertHttpAttributed<T>() {\n    foreach (var m in typeof(T).GetMethods())\n        if (m.DeclaringType == typeof(T) && m.GetCustomAttribute<HttpMethodAttribute>() is null)\n            throw new InvalidOperationException($\"{m.Name} is missing an HTTP method attribute.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add an HTTP method attribute to every method on the Refit interface.","Keep non-HTTP members off the interface.","Run a startup reflection check over registered interfaces."],"tags":["refit","attributes","http-method","reflection","design-time"],"backgroundTag":null,"analyzedSha":"b455f65ecc4c97d092317e349cb775f9cfc6bcdf","analyzedAt":"2026-08-13T21:20:57.878Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}