Skip to content

Commit bab391a

Browse files
committed
Fix error with updating repeated keys
1 parent 8722a47 commit bab391a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

R/utils.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ req_body_form_modify <- function(req, ..., .multi = "error", .call = caller_env(
5959
if (is.null(req$body) || req$body$type != "form") {
6060
cli::cli_abort("Can only be used after {.fn httr2::req_body_form}", call = .call)
6161
}
62-
new_body <- utils::modifyList(req$body$data, data)
62+
# Allow for repeated names in data: since R tools don't play nicely with this
63+
# situation, remove all modified entries from data first.
64+
new_body <- utils::modifyList(req$body$data[!names(req$body$data) %in% names(data)], data)
6365
httr2::req_body_form(req, !!!new_body, .multi = .multi)
6466
}
6567

@@ -135,4 +137,4 @@ check_scalar_integer <- check_arg(rlang::is_scalar_integer, "a scalar integer")
135137
check_scalar_positive_integer <- check_arg(
136138
\(x) rlang::is_scalar_integer(x) && x > 0L,
137139
"a positive scalar integer"
138-
)
140+
)

0 commit comments

Comments
 (0)