s3-server
s3-server copied to clipboard
Server Response Date Format Issue
Error Description
I am writing to report an issue I encountered while attempting to access the server using rclone. The problem arises from a discrepancy in the date format used by the server's response and the one expected by the client.
The server's response uses the date format 2023-09-29T17:44:42.444222818+02:00, while the client expects the date format 2006-01-02T15:04:05.999999999Z.
I have tested this with multiple clients, including ExpanDrive and S3 Explorer, and have consistently encountered the same issue.
logs
Response {
status: 200,
version: HTTP/1.1,
headers: {
"content-type": "text/xml",
},
body: Body(
Full(
b"<?xml version=\"1.0\" encoding=\"UTF-8\"?><ListAllMyBucketsResult><Buckets><Bucket><CreationDate>2023-09-29T17:44:42.444222818+02:00</CreationDate><Name>neuerbucket</Name></Bucket><Bucket><CreationDate>2023-09-29T15:46:25.769964989+02:00</CreationDate><Name>bsp</Name></Bucket></Buckets></ListAllMyBucketsResult>",
),
),
}
Output of rclone:
(venv) ➜ boto3_tmp rclone -vv lsd local-s3-bsp:
2023/09/29 18:35:09 DEBUG : rclone: Version "v1.50.2" starting with parameters ["rclone" "-vv" "lsd" "local-s3-bsp:"]
2023/09/29 18:35:09 DEBUG : Using config file from "/home/user/.config/rclone/rclone.conf"
2023/09/29 18:35:56 ERROR : : error listing: SerializationError: failed to decode REST XML response
status code: 200, request id:
caused by: parsing time "2023-09-29T17:44:42.444222818+02:00" as "2006-01-02T15:04:05.999999999Z": cannot parse "+02:00" as "Z"
2023/09/29 18:35:56 Failed to lsd with 2 errors: last error was: SerializationError: failed to decode REST XML response
status code: 200, request id:
caused by: parsing time "2023-09-29T17:44:42.444222818+02:00" as "2006-01-02T15:04:05.999999999Z": cannot parse "+02:00" as "Z"
(venv) ➜ boto3_tmp
hotfix
I managed to resolve the aforementioned date format issue by defining a function that corrects the date format. Here is the function in Rust:
use chrono::{DateTime, Utc};
pub fn correct_date_format(date_str: &String) -> String {
let date = DateTime::parse_from_rfc3339(date_str).unwrap();
let utc_date = date.with_timezone(&Utc);
let utc_date_str = utc_date.format("%Y-%m-%dT%H:%M:%S%.9fZ").to_string();
utc_date_str
}
This function was then invoked during the creation of the XML response. For instance, in the list_buckets.rs file, I replaced the following line: (https://github.com/datenlord/s3-server/blob/master/src/ops/list_buckets.rs#L47)
w.opt_element("CreationDate", bucket.creation_date)?;
with:
use crate::date_correction::correct_date_format;
let utc_date_str = correct_date_format(&bucket.creation_date.unwrap());
w.opt_element("CreationDate", Some(utc_date_str))?;
I needed so implement the hotfix for some other endpoints as well.
I would appreciate it if you could look into this matter and provide a solution. Thank you for your time and assistance.
https://github.com/datenlord/s3-server/issues/137
Yeah, I noticed it by myself.
Maybe it makes sense to update the README. I was reading a lot of stuff before I figured it out. Anyway - thanks for this project. It is exactly what I am looking for.
The easiest thing might be for the old maintainers to put the repository in Archive mode. Github usually puts enough stuff on the UI to let you know the repository isn't active then.
CC @Nugine