-
Notifications
You must be signed in to change notification settings - Fork 25
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
NUL Byte on Request.body when processing post on Julia 1.11-beta-1 #186
Comments
I think this may be an issue with HTTP.jl. I tried running the example on their website (https://juliaweb.github.io/HTTP.jl/stable/examples/#Simple-Server) and got a similar error:
Please note that I added the # "service" functions to actually do the work
function createAnimal(req::HTTP.Request)
@info req.body
animal = JSON3.read(req.body, Animal)
animal.id = getNextId()
ANIMALS[animal.id] = animal
return HTTP.Response(200, JSON3.write(animal))
end |
Yep, these two issues seem related: |
Hi @Westat-Transportation, From a quick glance, this looks more like a json serialization issue from the JSON3.jl library which doesn't allow those embedded nulls in json strings. I'd recommend taking a look at how you're sending data to see if it's accidently getting added to the body of the request. Something is probably getting added to your body when making the request. If there's nothing you change from your end, i'd recommend raising this issue on the JSON3.jl page with your examples. If you want to get things working NOW, you could always create a middleware to filter out the "0x00" from the first place in all request bodies. |
The same requests work with Julia 1.10, the error only happens on 1.11. The problem happens before we call JSON3, if you look at the output of the @info statement you can see that the contents of the body are corrupt. So, I don't think this is a de-serialization issue. Whatever the problem is here, it's replacing the first character with "0x00", so middleware would not be correct as we would have no way of knowing what that first character should have been... |
Hi @Westat-Transportation, Sorry about that, you're absolutely right. I skimmed over that detail when I first read it. Like you mentioned, this appears to be a HTTP.jl issue which will need to be patched from their end |
Yep, I agree and cross tagged issues from HTTP.jl to make them more aware. Thanks for responding. |
I tried to test an API we are developing on the latest Julia 1.11 beta-1 version and ran into an issue. What's happening is that the first byte that comes through in the body of post requests is
0x00
. Here's some sample code that sets up the server:And here's the output on the REPL when we make a post request to this server for the
/login
endpoint:The text was updated successfully, but these errors were encountered: