Skip to content

[Bug]: Issue with case differing path/query parameters #2356

Closed

Description

@lilinus

Describe the bug 🐞

Hi, I'm getting an exception when trying to use Refit for an endpoint that has parameters in path and query that only differs by case (id vs ID). The issue comes from a real-world OAS file, and from what I gather they should be considered as non-conflicting?

I get the same exception for generated and reflection-based clients.

Repro is based on interface that was generated by using refitter from OAS file. Issue in refitter repo: christianhelle/refitter#1338

Step to reproduce

#:sdk Microsoft.NET.Sdk
#:property TargetFramework=net10.0
#:property ImplicitUsings=enable
#:property Nullable=enable
#:package [email protected]
#:package [email protected]

using Microsoft.Extensions.DependencyInjection;
using Refit;

await using var sp = new ServiceCollection()
    .AddSingleton<TestHandler>()
    .AddRefitClient<IRepro>()
        .ConfigureHttpClient(c => c.BaseAddress = new Uri("https://localhost:5001"))
        .ConfigurePrimaryHttpMessageHandler<TestHandler>()
    .Services.BuildServiceProvider();
var repro = sp.GetRequiredService<IRepro>();
await repro.GetPositions(1, 2);

interface IRepro
{
    [Get("/api/accounts/{id}/positions")]
    Task GetPositions(int id, [Query, AliasAs("ID")] int? iD);
}

class TestHandler : HttpMessageHandler
{
    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        throw new NotImplementedException();
    }
}

Reproduction repository

No response

Expected behavior

The program should enter the test handler with URL https://localhost:5001/api/accounts/1/positions?ID=2

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

Refit Version

16.3.0

Additional information ℹ️

Stack trace:

System.ArgumentOutOfRangeException
  HResult=0x80131502
  Message=Specified argument was out of the range of valid values.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at Refit.GeneratedRequestRunner.BuildRequestPath(String relativePathTemplate, Boolean allowUnmatchedParameter, ReadOnlySpan`1 uriParams) in D:\a\refit\refit\src\Refit\GeneratedRequestRunner.cs:line 128
   at Refit.Implementation.GeneratedRefitTest.IRepro.GetPositions(Int32 id, Nullable`1 iD) in obj\Release\net10.0\InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\IRepro.g.cs:line 56
   at Program.<<Main>$>d__0.MoveNext() in Program.cs:line 11
   at Program.<<Main>$>d__0.MoveNext() in Program.cs:line 11
   at Program.<Main>(String[] args)

Activity

  1. glennawatson commented on Oct 14, 2026

    @glennawatson
    Contributor

    Thanks. Will take a look over the weekend for you.

  2. github-actions commented on Nov 16, 2026

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  3. locked and limited conversation to collaborators on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions