Open ArtemyB opened 3 years ago
Hi @ArtemyB I haven't seen this error before 🤔 maybe if you can share the return types that are failing, I could also take a look there?
Just to make sure, can you check if using the latest v2.19.0 of Fable.Remoting.Json solves this issue?
@Zaid-Ajaj sorry for the answer delay: posted the issue and went away from the PC :) But now I'm back and already have tried the recent Fable.Remoting.Json v2.19.0 -- no success, still get the error. However I've looked through the data being serialized in my error-prone Remoting-function and have noticed a pattern: all error-returning calls contain at least one value that looks like Some <DU Case>
whereas all successful calls contain value None
in these places (in that piece of data I have a record one of the fields of which has type like SomeDU option
, where SomeDU
: type SomeDU = | Case1 | Case2 | Case3
). So maybe this is the problem source -- either it's just Option
with DU or DUs with nested DUs in general.
Hmm, there is also a value of type like Some { R = 102uy; G = 51uy; B = 255uy; A = 255uy }
in data serialized during error calls whereas in successful cases there is value None
in the similar place (it is a value of another record's field). So type signature of this field is Color option
, where Color
: type Color = { R: byte; G: byte; B: byte; A: byte }
.
https://github.com/Zaid-Ajaj/Fable.Remoting/issues/268#issuecomment-903133614
Probably Option with DU is not the reason -- one other field of the same record also has type AnotherDU option
and its value is Some ...
in some of the successful remoting function calls.
Hi @ArtemyB I am looking at the issue again and I am able to reproduce the problem :/ any chance you could post an exact type of the API (and the all the types used in it) so that I can debug it? Creating a full sample repository to demonstrate the problem would be really helpful for me as well
@Zaid-Ajaj hi. Understood, I'll revisit the project on this weekend and extract problematic fragment to a separate sample.
P.S.: Only a guess: my problem could be connected with PR #254 (don't know how exactly -- simply it looks like the major update between Fable.Remoting.Json v2.16.0 and v2.17.0; + it affects unions and other types serialization)
Hi @ArtemyB is this still an issue for you from the latest versions? If so, please consider posting a sample project that I can test with
Hi @Zaid-Ajaj error still there, I have a repro https://github.com/brud/safe-stack-remoting-issue-repro I also deleted the build project - readme contains the actual commands to start the projects.
@Zaid-Ajaj should I create a new issue for that?
@Zaid-Ajaj I apologize fo such a huge delay, but I simply haven't touched that troubled project, leaving it on the old version of Fable.Remoting. And extracting repro from it required quite a lot of work (the project was kind of a mess), so I simply couldn't get a time and energy to do that.
However now, thanks to @brud and his repro, error's reason is finally revealed: both @brud's and my data has a DU with a case named Tag
. And whenever a value of this DU occurs (it could also be any other case from this DU, no only the Tag
), the "Ambiguous match found" error arises. As I understand it happens on the reflection level because DU's system Tag
property somehow conflicts with a user-defined Tag
case during Fable.Remoting.Json
's FableConverter
logic. Once I renamed my Tag
case, the error disappeared.
Note that I just tested on the recent Fable.Remoting.Json v2.21.0
, so I suspect the key change was introduced in v2.16.0
together with the DU serialization optimizations. Thus, the error is still present, however luckily knowing its origin, there is workaround 😌
Hi there @brud and thanks a lot for the repro. It is now clear what the problem with the diagnosis from @ArtemyB and how to fix it (not using Tag
as a DU case) I will reopen the issue and investigate it 😄
Recently after updating my project dependencies to the latest
Fable.Remoting.Giraffe
v5.4.0 (which requiresFable.Remoting.Json >= 2.18.0
) one of the API function in my Fable.Remoting handler started throwing an error "Ambiguous match found" in some cases. After a quick glance I haven't discovered any obvious pattern (had no time to look thoroughly). So more attentive search is required, because the error occurs only for some instances of the return type (i.e. in some cases the same API function succeeds and in other cases it fails) -- I'll explore this later. But judging by the stack trace I suspect it is related to unions serialization.At the same time there is no error when I use
Fable.Remoting.Json 2.16.0
(requires at leastFable.Remoting.Giraffe 5.7.0-rc-6
andFable.Remoting.Server 5.21.0
).The exception stack trace: