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

Bug: Http plugin fails when request body contains a string that is not valid JSON #196

Open
krisbitney opened this issue Aug 7, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@krisbitney
Copy link
Contributor

krisbitney commented Aug 7, 2023

When the body of a post request is not a valid JSON string, I encounter an exception. However, the HTTP interface schema says Request can contain any string.

The exception:

"PluginWrapper: invocation exception encountered.\nexception: \"Error parsing JSON: `expected value at line 1 column 1`\""`>

The invocation that produces the exception:

@Test
fun post() {
    val result: InvokeResult<Types.Response?> = client.invoke(
        uri = uri,
        method = "post",
        args = Types.ArgsPost(
            url = "https://httpbin.org/post",
            request = Types.Request(
                body = "Hello World!",
                responseType = Types.ResponseType.TEXT
            )
        )
    )

    assertNull(result.exceptionOrNull())
    assertEquals(200, result.getOrThrow()?.status)
}

Additional context:
https://discord.com/channels/796821176743362611/1010304976406454323/1138196489143857277

@krisbitney krisbitney added the bug Something isn't working label Aug 7, 2023
@krisbitney krisbitney changed the title Bug: Http plugin fails when trying to parse empty JSON Bug: Http plugin fails when request body contains a string that is not valid JSON Aug 7, 2023
@cbrzn
Copy link
Collaborator

cbrzn commented Aug 14, 2023

hey @krisbitney would it make sense to say that this might be a problem for all implementations of the http plugin rather than only the rust impl?

@krisbitney
Copy link
Contributor Author

hey @krisbitney would it make sense to say that this might be a problem for all implementations of the http plugin rather than only the rust impl?

I don't know but possibly. Per the discord conversation, it might make sense for us to change the http request body type to Bytes, or to assume the body String can sometimes be a base64 string.

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

2 participants