8000 [BUG] Adding a parameter twice to the url template triggers exception · Issue #1052 · reactiveui/refit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[BUG] Adding a parameter twice to the url template triggers exception #1052
Closed
@hansmbakker

Description

@hansmbakker

Describe the bug
Repeating the same parameter name multiple times in the url template causes Refit to crash at runtime

Steps To Reproduce
The repeated zoneId parameter in the code below causes the generated Refit code to crash at runtime. The exception is:
System.ArgumentException: An item with the same key has already been added.

[Get("/goform/formZone{zoneId}_Zone{zoneId}XmlStatusLite.xml")]
Task<Schema.ZoneStatus.ZoneStatus> IDenonHttpClient.GetDenonSecondaryZonesStatusAsync(int zoneId, CancellationToken cancellationToken)

Expected behavior
The code does not crash.

Screenshots

Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: 0
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at Refit.RestMethodInfo.BuildParameterMap(String relativePath, List`1 parameterInfo) in /_/Refit/RestMethodInfo.cs:line 178
   at Refit.RestMethodInfo..ctor(Type targetInterface, MethodInfo methodInfo, RefitSettings refitSettings) in /_/Refit/RestMethodInfo.cs:line 68
   at Refit.RequestBuilderImplementation.AddInterfaceHttpMethods(Type interfaceType, Dictionary`2 methods) in /_/Refit/RequestBuilderImplementation.cs:line 76
   at Refit.RequestBuilderImplementation..ctor(Type refitInterfaceType, RefitSettings refitSettings) in /_/Refit/RequestBuilderImplementation.cs:line 52
   at Refit.RequestBuilderImplementation`1..ctor(RefitSettings refitSettings) in /_/Refit/RequestBuilderImplementation.cs:line 19
   at Refit.RequestBuilderFactory.Create[T](RefitSettings settings) in /_/Refit/RequestBuilderFactory.cs:line 15
   at Refit.RequestBuilder.ForType[T](RefitSettings settings) in /_/Refit/RequestBuilder.cs:line 21
   at Refit.RestService.For[T](HttpClient client, RefitSettings settings) in /_/Refit/RestService.cs:line 18
   at Refit.RestService.For[T](String hostUrl, RefitSettings settings) in /_/Refit/RestService.cs:line 27

Environment

  • Version: Refit 5.2.4

Additional context
A workaround is to add another parameter with a different name having the same value.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0