-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
Description
Description
RouteCollectionReader.GetString converts string values containing large numbers to scientific notation, causing precision loss for int64 values.
Minimal Reproduction
open Microsoft.AspNetCore.Http
open Falco
[<EntryPoint>]
let main _ =
let ctx = DefaultHttpContext()
ctx.Request.RouteValues.Add("id", "9223372036854775807") // Int64.MaxValue as string
// The raw value is correct
let rawValue = ctx.Request.RouteValues.["id"]
printfn "Raw type: %s" (rawValue.GetType().Name) // "String"
printfn "Raw value: %s" (rawValue.ToString()) // "9223372036854775807"
// But GetString converts it
let route = Request.getRoute ctx
let strValue = route.GetString "id"
printfn "GetString: %s" strValue // "9.223372036854776E+18" (wrong!)
0Expected Behavior
GetString "id" should return "9223372036854775807" - the same string that was stored in RouteValues.
Actual Behavior
GetString "id" returns "9.223372036854776E+18" - the value has been converted through a floating-point type, losing precision.
Impact
This breaks int64 route parameter parsing for values larger than ~15 significant digits.
Environment
- Falco 5.2.0
- .NET 10.0
Workaround
Read directly from ctx.Request.RouteValues instead of using GetString:
match ctx.Request.RouteValues.TryGetValue(fieldName) with
| true, value when not (isNull value) -> value.ToString()
| _ -> ""Reactions are currently unavailable