Skip to content

RouteCollectionReader.GetString converts large numeric strings to scientific notation #149

Description

@michaelglass

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!)

    0

Expected 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()
| _ -> ""

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingv6

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions