fix(list): panic when creation_date_utc is null#182
Conversation
Can't use `serde(default)` here because `serde(default)` only handles when the field is missing (undefined). It will panic if a null value is found and the field is not defined as optional.
|
I can't reproduce the panic. Neither on Linux, nor on macOS. I have to look into this, because I did some research before I implemented it that way, but this was some time ago. I only added the default text, so that it shows a text instead of an empty cell (when using pretty output). Also, it can only be not defined, if you use an older server version that doesn't support (and thus send) the creation time. I'm heading to bed now. I can have a look at it tomorrow afternoon/evening. |
|
Thank you for having a look! Here's how I reproduce it on my Linux system (with docker): DetailsFirst, clone the git clone 'https://github.com/orhun/rustypaste.git'
cd rustypasteMake some change to the provided
Create the mkdir upload
sudo chown 1000:1000 uploadThen just run Upload a file: curl -sS -H 'Authorization: super_secret_token1' -F 'file=@Dockerfile' 127.0.0.1:8000Check the list returned by the server: curl -sS -H 'Authorization: super_secret_token1' 127.0.0.1:8000/listI can see this result: [{"file_name":"hydrocarbonaceous-charisse.txt","file_size":547,"creation_date_utc":null,"expires_at_utc":null}]In which the Now try with the git clone 'https://github.com/orhun/rustypaste-cli'
cd rustypaste-cli
cargo build --release
./target/release/rpaste --pretty --list --auth 'super_secret_token1' --server http://127.0.0.1:8000/I got this error: Here are some clues I currently have.
|
tessus
left a comment
There was a problem hiding this comment.
Thanks, I have also looked into it and your analysis makes sense. The main issue is that musl does not support the statx call and then the other factors lead to the panic.
It seems that this will be solved when rust is upgrading to musl 1.2.5. Until then, this seems like a great solution.
Thanks for the fix.
I was trying
rpaste -land found that it panics.After some digging, I found that the code used the
serde(default)macro to set a default value for the creation date when it's not available.As this issue of serde points out, the macro is only useful when the field is undefined (instead of null), so it cannot be used here.
Note: I'm using a musl build of the rustypaste server, and it always returns null for the creation date.