[GODRIVER-1945] Improved error messages Created: 31/Mar/21  Updated: 30/Mar/22

Status: Backlog
Project: Go Driver
Component/s: Error Handling
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Eric Milkie Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Currently, the error messages that can result from socket problems reading a server's response are confusing. For example, this one
https://github.com/mongodb/mongo-go-driver/blob/ea02175e9e44795efdda597ebd94b11d746d3984/x/mongo/driver/topology/connection.go#L470
can result in a message like "incomplete read of message header" for a context of "read tcp 192.168.248.6:38030->192.168.248.6:27000: i/o timeout" in response to a socket timeout expiring. This message isn't accurate because this particular function call is reading more than a message header, and because "incomplete" incorrectly implies at least one message header byte was successfully read. Driver consumers should not need to know these items of detail anyway.

Instead, to make error diagnosis easier for driver consumers, can we change the error messages in this function to be something like "socket error reading server response"? The context that gets appended to this message should have sufficient further detail already.



 Comments   
Comment by Eric Milkie [ 09/Apr/21 ]

We could use that wording, but it's still not useful for driver consumers, only for driver developers with access to the source code. An expected error in this location is "socket timeout" (and there is an implied mitigation for users if they see this phrasing); any other errors such as only 2 bytes read would be unexpected and there would be no user mitigation for that other than to talk to MongoDB engineering.

Comment by Divjot Arora (Inactive) [ 09/Apr/21 ]

The specific error message mentioned in the ticket is returned specifically when there's an error reading the first four bytes of a wire message, which contain the full length of the message. The "incomplete read of message header" wording is awkward because it's not clear what "incomplete" means and the phrase "message header" may not be obvious for a user of the driver. We can update this to something like "error reading first four length bytes of the server response".

Generated at Thu Feb 08 08:37:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.