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

Parse timestamp can return nil. Check for nil. #187

Merged
merged 1 commit into from
Sep 13, 2019

Conversation

n3wscott
Copy link
Member

@nachocano found a npe in his logs. I think this will fix.

Signed-off-by: Scott Nichols <nicholss@google.com>
@nachocano
Copy link
Contributor

LGTM

Copy link
Contributor

@markpeek markpeek left a comment

Choose a reason for hiding this comment

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

Just a couple of comments but LGTM for merging.

if err := ec.SetTime(timestamp.Time); err != nil {
return err
if t, ok := h[prefix+"time"].(string); ok {
if timestamp := types.ParseTimestamp(t); timestamp != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Right now ParseTimestamp() doesn't return an error. It's debatable on what to do if there is a bad time being presented whether to fail entirely or, as in the case, silently drop. Perhaps open an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

good points, I was optimizing for moving fast but it is true that this could catch someone off guard... I caught myself off guard. :D

@@ -187,16 +187,16 @@ func (c Codec) fromAttributes(a map[string]string, event *cloudevents.Event) err
delete(a, prefix+"source")

if t := a[prefix+"time"]; t != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks suspiciously similar to the amqp codec code. Perhaps there needs to be helpers in the main code for the codecs to use.

Copy link
Member Author

Choose a reason for hiding this comment

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

they use a slightly different mapping ... grrrr

I have some ideas how to combine them and pass a mapping decoder ring for the future.

@markpeek markpeek merged commit 4cc108a into cloudevents:master Sep 13, 2019
n3wscott added a commit to n3wscott/sdk-go that referenced this pull request Sep 20, 2019
Signed-off-by: Scott Nichols <nicholss@google.com>
n3wscott added a commit to n3wscott/sdk-go that referenced this pull request Sep 20, 2019
Signed-off-by: Scott Nichols <nicholss@google.com>
n3wscott added a commit that referenced this pull request Sep 20, 2019
* starting to add context for 0.4

Signed-off-by: Scott Nichols <nicholss@google.com>

* Enabling Pub/Sub to send and receive from multiple topics and subscriptions. (#171)

Signed-off-by: Scott Nichols <nicholss@google.com>

* Code and examples for proposed changes/additions to transport APIs (#164)

Please see the code and doc for details.

Signed-off-by: Alan Conway <aconway@redhat.com>
Signed-off-by: Scott Nichols <nicholss@google.com>

* fix a syntax error in a logw line. (#174)

Signed-off-by: Scott Nichols <nicholss@google.com>

* Changing Send signature: Adding Context return param (#177)

Signed-off-by: nachocano <nachoacano@gmail.com>
Signed-off-by: Scott Nichols <nicholss@google.com>

* Renamed pkg/cloudevents/transport/x to pkg/binding (#181)

Main types are binding.Message, binding.Sender and binding.Receiver which
reads well in code, corresponds to CE spec use of the term "binding", and
avoids clashes with existing package name "transport".

Part of #180 - The AMQP transport will be re-factored to use this package.

Signed-off-by: Alan Conway <aconway@redhat.com>
Signed-off-by: Scott Nichols <nicholss@google.com>

* fix extra header write. (#179)

Signed-off-by: Scott Nichols <nicholss@google.com>

* fix codec v0.3 double quote encoding (#184)

Signed-off-by: Diego Marangoni <diegomarangoni@me.com>
Signed-off-by: Scott Nichols <nicholss@google.com>

* Propagate pubsub subscriber errors (#185)

* Found a blocking issue on pubsub transport if a subscriber had an error.

Signed-off-by: Scott Nichols <nicholss@google.com>

* make sure cancel is called

Signed-off-by: Scott Nichols <nicholss@google.com>

* go mod.

Signed-off-by: Scott Nichols <nicholss@google.com>
Signed-off-by: Scott Nichols <nicholss@google.com>

* Fix nil pointer exception in codec timestamp handling (#187)

Signed-off-by: Scott Nichols <nicholss@google.com>

* Leaked a debug line. (#189)

Signed-off-by: Scott Nichols <nicholss@google.com>

* preping for v1.0, adjusting the interfaces.

Signed-off-by: Scott Nichols <nicholss@google.com>

* fix a typo on the godoc.

Signed-off-by: Scott Nichols <nicholss@google.com>
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.

3 participants