Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomization endpoint should not respond with internall server error on data validation #70

Open
lwalejko opened this issue Feb 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lwalejko
Copy link
Collaborator

This test case suggests that there is unhandled validation case for this endpoint:

test_that("request with patient that is assigned an arm at entry", {
response <- request(api_url) |>
req_url_path("study", "minimisation_pocock") |>
req_method("POST") |>
req_body_json(
data = list(
identifier = "ABC-X",
name = "Study ABC-X",
method = "var",
p = 0.85,
arms = list(
"placebo" = 1,
"active" = 1
),
covariates = list(
sex = list(
weight = 1,
levels = c("female", "male")
),
weight = list(
weight = 1,
levels = c("up to 60kg", "61-80 kg", "81 kg or more")
)
)
)
) |>
req_perform()
response_body <-
response |>
resp_body_json()
response_current_state <-
tryCatch(
{
request(api_url) |>
req_url_path("study", response_body$study$id, "patient") |>
req_method("POST") |>
req_body_json(
data = list(
current_state =
tibble::tibble(
"sex" = c("female", "male"),
"weight" = c("61-80 kg", "81 kg or more"),
"arm" = c("placebo", "control")
)
)
) |>
req_perform()
},
error = function(e) e
)
testthat::expect_equal(
response_current_state$status, 500,
label = "HTTP status code"
)
})

We should always validate input data in a way that will prevent the app from returning Internal Server Errors.

@lwalejko lwalejko added the bug Something isn't working label Feb 27, 2024
lwalejko added a commit that referenced this issue Feb 29, 2024
…d-not-respond-with-internall-server-error-on-data-validation

Issue #70: Status code changed from 500 to 400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant