-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-424: Validate that RP tag set is an array of documents #399
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
Conversation
|
||
switch(ZEND_NUM_ARGS()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except for:
- the single error message change
@@ -28,4 +32,6 @@ OK: Got MongoDB\Driver\Exception\InvalidArgumentException | |||
Unsupported readPreference value: 'nothing' | |||
OK: Got MongoDB\Driver\Exception\InvalidArgumentException | |||
Primary read preference mode conflicts with tags | |||
OK: Got MongoDB\Driver\Exception\InvalidArgumentException | |||
Read preference tags must be an array of zero or more documents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should say "Primary read preference mode conflicts with tags". It doesn't matter whether they're valid or not yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more consistent with the ReadPreference constructor. We're validating individual values before we check the combined state of the read preference. Of course, they'll end up seeing both exceptions in due time (the second will appear after they resolve the first issue).
On that note, I think there's an oversight in php_phongo_apply_rp_options_to_uri()
where we're never checking if "maxstalenessms" is a positive value. As-is, I think a negative value would only trigger a generic "Read preference is not valid" error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added another case to the ReadPreference ctor test to demonstrate that it also reports invalid tag set structure first (before the primary conflict).
This adds common validation for read preference tag sets when specified through either the Manager constructor's URI options array or ReadPreference constructor. An additional test case for a malformed tag set has been added to the Manager::__construct() error test for read preference options. Additionally, the ReadPreference::__construct() error test has been split up to test for mode and tagSet errors separately. Note: we cannot test for the exceptions for bson_init_static() and mongoc_read_prefs_is_valid(), since those points will never be hit in normal operation.
https://jira.mongodb.org/browse/PHPC-424
This adds common validation for read preference tag sets when specified through either the Manager constructor's URI options array or ReadPreference constructor.
An additional test case for a malformed tag set has been added to the Manager::__construct() error test for read preference options. Additionally, the ReadPreference::__construct() error test has been split up to test for mode and tagSet errors separately.
Note: we cannot test for the exceptions for bson_init_static() and mongoc_read_prefs_is_valid(), since those points will never be hit in normal operation.