Skip to content

bug: c stack usage in form body request #805

@JosiahParry

Description

@JosiahParry

The below request causes Error: C stack usage 16917613 is too close to the limit.
The issue is that the features parameter is a json string that is 16mb.

library(httr2)

feats <- brio::read_file("features.json")
format(object.size(feats), "Mb")

req <- request("https://httpbin.org/post") |> 
  req_body_form(
    features = feats,
    f = "json"
  )

The traceback is:

1. format.default(x, scientific = FALSE, trim = TRUE, justify = "none")
2. format(x, scientific = FALSE, trim = TRUE, justify = "none")
3. (function (x, name, multi = FALSE, form = FALSE, error_call = caller_env()) 
   {
       check_query_param(x, name, multi = multi, error_call = error_call)
       if (inherits(x, "AsIs")) {
           unclass(x)
       }
       else if (is_obfuscated(x)) {
           x
       }
       else {
           x <- format(x, scientific = FALSE, trim = TRUE, justify = "none")
           x <- curl::curl_escape(x)
           if (form) {
               x <- gsub("%20", "+", x, fixed = TRUE)
           }
           x
       }
   })(dots[[1L]][[1L]], dots[[2L]][[1L]], form = FALSE, error_call = <environment>)
4. mapply(.f, .x, .y, MoreArgs = list(...), SIMPLIFY = FALSE)
5. map2(.x, names(.x), .f, ...)
6. imap(dots[n == 1], format_query_param, form = form, error_call = error_call)
7. multi_dots(..., .multi = .multi)
8. req_body_form(request("https://httpbin.org/post"), features = feats, 
       f = "json")

The json file can be found here: features.json

Background:

A customer using arcgislayers reported this issue. They are publishing very detailed geographies. in this case, just one of the geometries in question has 430k vertices. I will see if there are alternative ways that our services can accept new geometries outside of json.

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