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

Timezone parsing errors / misbehavior #34

Open
moxious opened this issue Mar 26, 2018 · 3 comments
Open

Timezone parsing errors / misbehavior #34

moxious opened this issue Mar 26, 2018 · 3 comments
Assignees

Comments

@moxious
Copy link
Collaborator

moxious commented Mar 26, 2018

{"name":"requests",
"startTime":"2018-03-26T12:39:55",
"endTime":"2018-03-26T12:39:55",
"value":{ 
  "int64Value": 10,
  "labels":{"foo":"Bar"}
 }
}

Sample input (as t.json)

Posting this:

$ curl -X post -d @t.json http://localhost:3456/report
parsing time ""2018-03-26T12:39:55"" as ""2006-01-02T15:04:05Z07:00"": cannot parse """ as "Z07:00"/ # 

Assuming timezone UTC (Z) would have made sense, but not sure where the 07:00 offset is coming from, this looks like a bug.

@moxious
Copy link
Collaborator Author

moxious commented Mar 26, 2018

Related to this, in the example curl statement used to show how ubbagent is used, it looks like this:

date -u +"%Y-%m-%dT%H:%M:%S.%NZ"

This produces output like 2018-03-26T12:55:49.NZ which is malformed and makes ubbagent fail.

This date format string works:

date -u +"%Y-%m-%dT%H:%M:%SZ"

@moxious
Copy link
Collaborator Author

moxious commented Mar 26, 2018

Date parsing errors make the HTTP agent very unhappy, it instantly closes the connection and returns nothing (not even HTTP 400*)

$ curl -v -X POST -d "{\"name\": \"requests\", \"startTime\": \"$(date -u +"%Y-%m-%dT%H:%M:%S.%NZ")\", \"endTime\": \"$(date -u +"%Y-%m-%dT%H:%M:%S.%NZ")\", \"value\": { \"int64Value\": 10 }, \"labels\": { \"foo\": \"bar2\" } }" 'http://localhost:3456/report'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3456 (#0)
> POST /report HTTP/1.1
> Host: localhost:3456
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 157
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 157 out of 157 bytes
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

jvolkman added a commit that referenced this issue Apr 18, 2018
Remove usage of '%N' in example `date` commands since it's not supported by some platforms. #34
@jvolkman
Copy link
Contributor

Regarding the timezone parsing error: this is a really horrible error message generated by Go's time library when parsing a timestamp in RFC3339 format. The "07:00" text comes from the format described here: https://github.com/golang/go/blob/master/src/time/format.go#L78. The message is basically telling you that a timezone is required: either "Z" or something like "+07:00". I'll see if I can wrap this in a more meaningful message.

The '%N' in the example curl command adds nanoseconds. I guess this is platform-dependent (and assume you're using OS X?). I've removed '%N' from the example commands.

And regarding the HTTP response: I'm not able to reproduce the closed connection. I get a 500 on parse error which, while not ideal, is at least a response, and is what I would expect given this line: https://github.com/GoogleCloudPlatform/ubbagent/blob/master/http/http.go#L56. Is the closed connection always reproducible for you?

@jvolkman jvolkman self-assigned this Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants