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

Replace time.Time.String() with time.Time.Format() #1017

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

MaryamTaj
Copy link

Resolves #987
Earlier, we used time.Time.String() to marshal time into a string. According to the go time.Time documentation however, time.Time.String() is only suitable for debugging purposes. This PR replaces time.Time.String with time.Time.Format() with RFC3339 to provide a stable serialized representation of time.

@@ -6,6 +6,7 @@ on:
- 'protocol/**' # Push events to matching protocol/foo/bar/v*, i.e. protocol/foo/bar/v1.0, protocol/foo/bar/v20.15.10
- 'observability/**' # Push events to matching observability/foo/bar/v*
- 'sql/**' # Push events to matching sql/v*
- 'binding/**' # Push events to matching binding/foo/bar/v*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be separate PR

README.md Outdated
@@ -27,7 +27,7 @@ _Note:_ Supported go version: 1.14+
Add the module as dependency using go mod:

```shell
go get github.com/cloudevents/sdk-go/v2@v2.4.1
go get github.com/cloudevents/sdk-go/v2@v2.5.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be separate PR (incl. the other ones)

Comment on lines 1 to 5
/*
Copyright 2021 The CloudEvents Authors
SPDX-License-Identifier: Apache-2.0
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be separate PR

Comment on lines -79 to +80
stream.WriteString(eventContext.Time.String())
stream.WriteString(eventContext.Time.Format(time.RFC3339))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran an example w/ Go 1.22 (same w/ Go 1.21) here: https://go.dev/play/p/NcMTqPu75fe

And I get:

2009-11-10 23:00:00 +0000 UTC m=+0.000000001
2009-11-10T23:00:00Z

Which could be considered a breaking change. WDYT?

cc/ @duglin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with the breaking change. I'm more bothered that:
1 - it wasn't spec compliant before and no one noticed
2 - not a single testcase needed to be changed

I agree with splitting the upgrade stuff into a separate PR. But can we also get at least one testcase added that checks the format of the time attribute and that it adheres to the CE spec (RFC3339) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get to work on it! Thank you so much for the feedback!

Copy link
Author

@MaryamTaj MaryamTaj Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned up the PR. Currently working on test cases:)

@MaryamTaj MaryamTaj force-pushed the issue-987 branch 2 times, most recently from a209c30 to 232dcc4 Compare February 24, 2024 23:56
@embano1 embano1 marked this pull request as draft March 22, 2024 08:02
@embano1
Copy link
Member

embano1 commented Mar 22, 2024

@MaryamTaj converted to draft, seems you're still working on this. Once ready for review, please just mark as "Ready for review" and ping us.

@duglin
Copy link
Contributor

duglin commented Jul 16, 2024

@MaryamTaj any update on this?

@MaryamTaj
Copy link
Author

MaryamTaj commented Jul 16, 2024

@duglin Hi Doug! I was running into some issues earlier, where all the tests pass locally but not on GitHub. I am going to try a new approach, and I'll let you know how it goes

@duglin
Copy link
Contributor

duglin commented Jul 16, 2024

ok thanks for the update.

@duglin
Copy link
Contributor

duglin commented Sep 26, 2024

@MaryamTaj any update on this?

@MaryamTaj
Copy link
Author

MaryamTaj commented Sep 29, 2024

@duglin I think I'm running into a wall. I tried to resolve as many errors as I could.
Below, I have outlined the errors I am still running into, and what I have tried so far. This way, anyone else opening this PR does not have to start from scratch. I hope that will help, and I am genuinely sorry for not being able to resolve the issue!
https://docs.google.com/document/d/1xfac9mAtsvB8RvqKN-Fz4F96W-VfdtivWGZitTi_QZg/edit?usp=sharing

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

Successfully merging this pull request may close these issues.

Properly marshal event time to RFC-3339 format
3 participants