Skip to content
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

Ignore disableMD5 option as md5 field is removed from the spec #1502

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Oct 29, 2024

The disableMD5 option is ignored. The behavior is to never write the md5 field, which is supported by upload tests.

Related to

@GromNaN GromNaN requested a review from a team as a code owner October 29, 2024 08:31
@GromNaN GromNaN requested a review from jmikola October 29, 2024 08:31
@alcaeus alcaeus requested review from alcaeus and removed request for jmikola October 29, 2024 08:32
Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

While it feels hacky to just unset the option, the alternative would be to re-add it to the schema but ignore it when actually executing commands. I don't think that is feasible.

// GridFS deprecated fields are removed
'gridfs/gridfs-upload-disableMD5: upload when length is 0 sans MD5' => 'Deprecated fields are removed',
'gridfs/gridfs-upload-disableMD5: upload when length is 1 sans MD5' => 'Deprecated fields are removed',
'gridfs/gridfs-upload: upload when contentType is provided' => 'Deprecated fields are removed',
Copy link
Member

Choose a reason for hiding this comment

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

Noted that this test was removed in mongodb/specifications@12be2df.

@@ -769,6 +769,10 @@ private function executeForSession(Session $session)
private function executeForBucket(Bucket $bucket)
{
$args = $this->prepareArguments();

// "md5" field is removed from the spec, option "disableMD5" is ignored
unset($args['disableMD5']);
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed to allow running upload-disableMD5.yml, which still exists in the upstream repository?

Those tests all assert md5: { $$exists: false }, so I'm not sure what it would matter. Wouldn't PHPLIB 2.x just ignore the option (vs. a possible deprecation notice in 1.x)?

Copy link
Member Author

@GromNaN GromNaN Oct 29, 2024

Choose a reason for hiding this comment

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

v2.x ignore the option.

  • If not set: md5 field is not set
  • If set to false: md5 field is not set ...

In v1.x, we talked about deprecating not setting disableMD5: true, but that was rejected because of the burden of having to set an option for something that is not used.

Copy link
Member

@jmikola jmikola Oct 29, 2024

Choose a reason for hiding this comment

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

I likely misunderstood the point of this change. Is it just being done to satisfy the Util.php check for unsupported options? If so, it'd be helpful to make a note of that in this comment (since I've just demonstrated how likely I am to misunderstand the purpose of this unset() ^_^).

No objections to merging after that.

Copy link
Member Author

Choose a reason for hiding this comment

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

After investigations, disableMD5 option is documented in the spec. So I added the option to the list of allowed options, with a comment.

Copy link
Member Author

@GromNaN GromNaN Oct 30, 2024

Choose a reason for hiding this comment

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

So I restored the option disableMD5 that I removed from the allowed options in #1398. Note that the spec document the option to create a bucket, not to call the upload method.

Copy link
Member

Choose a reason for hiding this comment

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

If spec tests actually use a disableMD5 option for upload operations, I think that's an oversight in the spec itself. The option should probably be added to File Upload with the same note it has on the corresponding bucket option (that it's deprecated and transitional).

Defer to you if that's worth doing at this point.

@GromNaN GromNaN force-pushed the ignore-disableMD5 branch 2 times, most recently from 15fc90a to 962c806 Compare October 30, 2024 07:29
tests/UnifiedSpecTests/Context.php Outdated Show resolved Hide resolved
tests/UnifiedSpecTests/Util.php Show resolved Hide resolved
@@ -499,7 +499,7 @@ private static function prepareCollectionOrDatabaseOptions(array $options): arra

private static function prepareBucketOptions(array $options): array
{
Util::assertHasOnlyKeys($options, ['bucketName', 'chunkSizeBytes', 'readConcern', 'readPreference', 'writeConcern']);
Util::assertHasOnlyKeys($options, ['bucketName', 'chunkSizeBytes', 'disableMD5', 'readConcern', 'readPreference', 'writeConcern']);
Copy link
Member

Choose a reason for hiding this comment

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

Per my earlier comment about no tests using bucketOptions, I doubt this change is required. But if you'd like to keep it, I think it warrants the same comment I suggested below in Util.php so any future reader understands why this option is still here.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct, this option is not necessary for the existing spec tests. But it should be allowed according to the spec.

Suggested change
Util::assertHasOnlyKeys($options, ['bucketName', 'chunkSizeBytes', 'disableMD5', 'readConcern', 'readPreference', 'writeConcern']);
Util::assertHasOnlyKeys($options, ['bucketName', 'chunkSizeBytes', 'readConcern', 'readPreference', 'writeConcern']);

@GromNaN GromNaN enabled auto-merge (squash) November 4, 2024 20:44
@GromNaN GromNaN disabled auto-merge November 4, 2024 20:45
@GromNaN GromNaN enabled auto-merge (squash) November 4, 2024 20:46
@GromNaN GromNaN merged commit 4faba13 into mongodb:v2.x Nov 7, 2024
30 checks passed
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.

3 participants