Skip to content

Improved encoding error handling#297

Merged
guelfey merged 4 commits intomasterfrom
feat/encoding_errors
Feb 5, 2022
Merged

Improved encoding error handling#297
guelfey merged 4 commits intomasterfrom
feat/encoding_errors

Conversation

@guelfey
Copy link
Member

@guelfey guelfey commented Jan 14, 2022

Closes #295.

Logging from library code is not nice, but the best way to handle invalid reply messages IMO in a compatible way since there's not really a mechanism to make this known to application code.

@guelfey guelfey requested a review from jsouthworth January 14, 2022 20:47
Copy link
Member

@jsouthworth jsouthworth left a comment

Choose a reason for hiding this comment

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

Some minor comments/questions. Otherwise looks good to me.

// Emit emits the given signal on the message bus. The name parameter must be
// formatted as "interface.member", e.g., "org.freedesktop.DBus.NameLost".
func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) error {
if !path.IsValid() {
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why are we dropping these checks?

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're redundant now as they're also done in msg.IsValid()

return InvalidMessageError("missing signature")
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Looks like a spurious empty line.

Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding this -- once #301 and #303 are merged, I will add more linters to CI, including those that will find things like this (and can also be used locally before sending a PR). Talking about golangci-lint and friends.

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good @kolyshkin, adding linting was also on my bucket list


conn.sendMessageAndIfClosed(reply, nil)
if err := reply.IsValid(); err != nil {
fmt.Fprintf(os.Stderr, "dbus: dropping invalid reply to %s.%s on obj %s: %s\n", ifaceName, name, path, err)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a huge fan of printing messages from libraries, but I don't have a better solution for this either.

@guelfey guelfey merged commit 587048b into master Feb 5, 2022
@guelfey guelfey deleted the feat/encoding_errors branch February 5, 2022 10:38
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.

Prevent encoding errors

3 participants