Skip to content

Incorrect handling of extra GET parameters #103

Description

@lwalejko

When there are GET parameters used that are not expected by the app, it returns Internal Server Error instead of Bad Request

<error/rlang_error>
unbiased-1  | Error in `z()`:
unbiased-1  | ! unused arguments (determinism = 0.85, character = 1, type = "sd")
unbiased-1  | ---
unbiased-1  | Backtrace:
unbiased-1  |   1. unbiased:::run_unbiased()
unbiased-1  |  69. unbiased (local) `<fn>`(...)
unbiased-1  |  70. base::withCallingHandlers(z(...), error = rlang::entrace)
unbiased-1  |        at unbiased/R/error-handling.R:63:5
unbiased-1  | Expected public_key, host and project_id to be present but can't find public_key, host, project_id.
unbiased-1  | <error/rlang_error>
unbiased-1  | Error in `audit_log$validate_log()`:
unbiased-1  | ! Event type not set for audit log. Please set the event type using `audit_log_event_type`
unbiased-1  | ---
unbiased-1  | Backtrace:
unbiased-1  |   1. unbiased:::run_unbiased()
unbiased-1  |   8. httpuv (local) `<fn>`(`<env>`, `<externalptr>`)
unbiased-1  |   9. httpuv:::rookCall(private$app$call, req, req$.bodyData, seek(req$.bodyData))
unbiased-1  |  14. httpuv (local) compute()
unbiased-1  |  15. plumber (local) func(req)
unbiased-1  |  16. self$serve(req, res)
unbiased-1  |  17. plumber:::runSteps(...)
unbiased-1  |  18. plumber:::runStepsUntil(...)
unbiased-1  |  23. plumber (local) runStep()
unbiased-1  |  24. plumber (local) nextStep(x)
unbiased-1  |  25. plumber:::runSteps(...)
unbiased-1  |  26. plumber:::runStepsUntil(...)
unbiased-1  |  31. plumber (local) runStep()
unbiased-1  |  32. plumber (local) nextStep(x)
unbiased-1  |  33. private$runHooks(...)
unbiased-1  |  34. plumber:::runSteps(...)
unbiased-1  |  35. plumber:::runStepsUntil(...)
unbiased-1  |  40. plumber (local) runStep()
unbiased-1  |  41. plumber (local) nextStep(x)
unbiased-1  |  43. unbiased (local) `<fn>`(req = `<env>`, res = `<PlmbrRsp>`)
unbiased-1  |  46. audit_log$validate_log()
unbiased-1  |        at unbiased/R/audit-trail.R:163:9
unbiased-1  | Expected public_key, host and project_id to be present but can't find public_key, host, project_id.
unbiased-1  | Error in run_now(check_time, all = FALSE) :
unbiased-1  |   Not compatible with requested type: [type=list; target=raw].
unbiased-1  | Calls: <Anonymous> -> invokeCppCallback

Example to reproduce issue:

import requests
import json

url = "http://127.0.0.1:3838/study/minimisation_pocock"
params = {
    "determinism": 0.85,
    "character": 1,
    "type": "sd"
}

payload = {
    "identifier": "CSN",
    "name": "Clinical Study Name",
    "method": "range",
    "p": 0.85,
    "arms": {
        "placebo": 1,
        "active": 1
    },
    "covariates": {
        "sex": {
            "weight": 1,
            "levels": [
                "female",
                "male"
            ]
        },
        "weight": {
            "weight": 1,
            "levels": [
                "up to 60kg",
                "61-80 kg",
                "81 kg or more"
            ]
        }
    }
}

response = requests.post(url, params=params, json=payload)

print(f"Status Code: {response.status_code}")
print(f"Content: {response.text}")

Will print

Status Code: 500
Content: An exception occurred.

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