fix(mango): correct behavior of fields on _explain#4751
Merged
pgj merged 1 commit intoapache:mainfrom Sep 8, 2023
Merged
Conversation
nickva
approved these changes
Sep 7, 2023
fe9bf30 to
d38ba73
Compare
The `fields` attribute on `_explain` might have the string value `"all_fields"` when the respective query parameter (`fields`) is not set by the user. This is to express that no projection of fields would happen on the returned documents. The current behavior contradicts with the current contract, because by documentation, `fields` is an array of strings instead to provide information on the projected fields. The discrepancy here makes it hard to formalize this in OpenAPI which leads to problems in the development of SDKs, among others. Change `_explain` to return `[]` for `fields` when it was not set through the query parameters. This is thought to be semantically equivalent to `"all_fields"` therefore this would not cause problems while preserving the promised type. Thanks @ricellis for reporting this problem!
d38ba73 to
36d847a
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
fieldsattribute on_explainmight have the string value"all_fields"when the respective query parameter (fields) is not set by the user. This is to express that no projection of fields would happen on the returned documents.The current behavior contradicts with the current contract, because by documentation,
fieldsis an array of strings instead to provide information on the projected fields. The discrepancy here makes it hard to formalize this in OpenAPI which leads to problems in the development of SDKs, among others.Change
_explainto return[]forfieldswhen it was not set through the query parameters. This is thought to be semantically equivalent to"all_fields"therefore this would not cause problems while preserving the promised type.Thanks @ricellis for reporting this problem!
Testing recommendations
Users who based their solution on utilizing the
"all_fields"response explicitly might need to change it to use[]instead. Otherwise they will not be affected by the change.Checklist
src/docsfolder