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

fix(mango): improve handling of unsatisfiable ranges in selectors #4568

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pgj
Copy link
Contributor

@pgj pgj commented May 3, 2023

Certain configurations of unsatisfiable field ranges could cause HTTP 500 because they are not handled, for example:

{"$and": [{"field": {"$eq": N}}, {"field": {"$gt": N}}]}

This makes mango_idx_view:end_key/1 fail because there is no clause to cover [{'$gt',35,'$eq',35}], the value that the selector becomes mapped to.

Similar field ranges are somewhat already handled by being mapped to empty so this seems to be an oversight in the original implementation. Consider the following case, which will not crash on the contrary:

{"$and": [{"field": {"$gt": N}}, {"field": {"$eq": N}}]}

Add the missing function clauses to fix this problem.

Checklist

  • Code is written and works correctly
  • Changes are covered by tests

Certain configurations of unsatisfiable field ranges could cause
HTTP 500 because they are not handled, for example:

    {"$and": [{"field": {"$eq": N}}, {"field": {"$gt": N}}]}

This makes `mango_idx_view:end_key/1` fail because there is no
clause to cover `[{'$gt',35,'$eq',35}]`, the value that the
selector becomes mapped to.

Similar field ranges are somewhat already handled by being mapped
to `empty` so this seems to be an oversight in the original
implementation.  Consider the following case, which will not
crash on the contrary:

    {"$and": [{"field": {"$gt": N}}, {"field": {"$eq": N}}]}

Add the missing function clauses to fix this problem.

Found by:	random query generation
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.

1 participant