Skip to content

PYTHON-2342 Prefer checking error codes over error messages #492

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

Merged
merged 3 commits into from
Oct 2, 2020

Conversation

ShaneHarvey
Copy link
Member

I've performed the following requests in the drivers ticket:

  • Audit the driver for uses of error messages to make decisions
  • For each error message, determine the server's related error code and check that first, falling back to error message matching to avoid breaking changes with old server versions.

For example, the Python driver does an exact match on the error message "ns not found". It should attempt to match error code 26 first, matching the error message as a fallback. The fallback is necessary to avoid a backward breaking change with MongoDB 2.6 and 3.0 which do not return an error code.

I also removed the "db assertion failure" check which was removed by the server in MongoDB 2.5.

Copy link
Member Author

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

Enabling "Hide whitespace changes" (w=1 in the url) makes this change easier to review: https://github.com/mongodb/mongo-python-driver/pull/492/files?diff=split&w=1

@@ -102,7 +102,7 @@ def _index_document(index_list):
return index


def _check_command_response(response, max_wire_version, msg=None,
Copy link
Member Author

Choose a reason for hiding this comment

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

msg was never used.

@ShaneHarvey
Copy link
Member Author

ShaneHarvey commented Sep 29, 2020

This is ready for review. I had to revert the PYTHON-2381 changes because of backwards compatibility concerns with 2.6/3.0.

@ShaneHarvey ShaneHarvey merged commit b2fba41 into mongodb:master Oct 2, 2020
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.

2 participants