[COMPASS-6703] Investigate changes in SERVER-68922: $natural parser should be stricter (reject NaN, etc) Created: 05/Apr/23  Updated: 05/Apr/23  Resolved: 05/Apr/23

Status: Closed
Project: Compass
Component/s: None
Affects Version/s: None
Fix Version/s: No version

Type: Investigation Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-68922 $natural parser should be stricter (r... Closed
Documentation Changes: Not Needed

 Description   
Original Downstream Change Summary

This change brings the server-side validation in line with what we say that we accept in our public documentation (see https://www.mongodb.com/docs/manual/reference/method/cursor.hint/#std-label-hint-collection-scans), so there should not be any documentation changes needed. However, sending downstream impact tickets to notify that we will now reject invalid inputs rather than interpreting them non-sensically.

Description of Linked Ticket

A $natural hint or sort is supposed to take a direction: +1 or -1. But the parser allows other values, such as 0, NaN, or -0.01. In 5.0 and later we define safeNumberInt() < 0 to mean descending, which means 0, NaN and -0.01 are ascending. In 4.4 and earlier we use the unsafe numberInt(), so whether NaN is ascending or descending depends on the platform.

We should reject all of these inputs with a clear error. We should also consider using the number() < 0 idiom for consistency with index keys and sort patterns.

It looks like this doesn't affect other hints and sorts, because we either validate the SortPattern, or check that the hint matches to an existing index key.



 Comments   
Comment by Jessica Sigafoos [ 05/Apr/23 ]

No action required from the DevTools team

Generated at Wed Feb 07 22:44:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.