Skip to content

Forwarded JSOn should have lowercase keys#11

Merged
ShimShtein merged 1 commit into
ShimShtein:mainfrom
ehelms:ensure-json
Jul 17, 2022
Merged

Forwarded JSOn should have lowercase keys#11
ShimShtein merged 1 commit into
ShimShtein:mainfrom
ehelms:ensure-json

Conversation

@ehelms

@ehelms ehelms commented Jun 10, 2022

Copy link
Copy Markdown
Collaborator

Golang uses capitalized variable names for JSON that is sent into
the yggdrasil service. When this data is forwarded, it needs to be
converted back to the proper JSON format to retain the same structure.

@ehelms

ehelms commented Jun 10, 2022

Copy link
Copy Markdown
Collaborator Author

Replaces #4 by adding some tests

Golang uses capitalized variable names for JSON that is sent into
the yggdrasil service. When this data is forwarded, it needs to be
converted back to the proper JSON format to retain the same structure.
@jeremy-audet

jeremy-audet commented Jun 10, 2022

Copy link
Copy Markdown

Bug tracked in SAT-10933.

@ehelms

ehelms commented Jun 21, 2022

Copy link
Copy Markdown
Collaborator Author

@ShimShtein Could you give this a review?

@adamruzicka adamruzicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM apart from the error handling which in general feels lacking

Comment thread server.go
Comment on lines +80 to +83
dataJson, error := json.Marshal(data)
if error != nil {
log.Fatal(error)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this is somewhat unlikely to happen and that this is just the error handling that was here before moved into a function, but it doesn't feel right. If the data cannot be encoded as json, we'd log an error message and send a post with an empty body to the server? Shouldn't it report the error back to the cloud and bail out?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Fatal method logs and exits in the same command: https://pkg.go.dev/log#Fatal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a bit surprising. Anyway, the worker dies and most likely gets restarted, but is the cloud notified somehow?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It depends on yggdrasil's error handling for the Send method. The method call would be aborted, so it will result in an error on the dispatcher side.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Soooo, what is my take away here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's leave it as is and hope yggdrasil can somehow deal with it I guess

@ShimShtein ShimShtein merged commit 3942064 into ShimShtein:main Jul 17, 2022
@ShimShtein

Copy link
Copy Markdown
Owner

Merged, thanks @ehelms !

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.

4 participants