-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Background
SERVER-125834 identified and fixed a spurious trailing / in $regularExpression.pattern values across the query-correctness-tests-4 reference files (merged as query-correctness-tests-4 PR #22). The root cause was an off-by-one in ValueWriter::toRegEx():
{{// BUG: rfind('/') returns an index, but substr() takes a length.
// Passing the index as the length includes the closing '/' delimiter.
return JSRegEx(regexStr.substr(1, regexStr.rfind('/')), // off by one
regexStr.substr(regexStr.rfind('/') + 1));}}
For /SMS/ this produced "pattern":"SMS/" instead of "pattern":"SMS". Fixed in mongo PR #52547 (SERVER-116052) by switching to JS::GetRegExpSource / JS::GetRegExpFlags.
Problem
The Evergreen patch run for SERVER-116052 (version 6a074f5f0f996d0007cb24f3) shows that query-correctness-tests-1, query-correctness-tests-2, and query-correctness-tests-3 all have the same trailing-slash bug in their reference files — every .results file where a $function expression returns a regex literal has an extra / in the "pattern" field. With the fix now active in the WASM engine, the corrected output no longer matches these stale references, causing ~50 failures per bucket (150 failures total).
Fix
For each of query-correctness-tests-1, query-correctness-tests-2, query-correctness-tests-3:
- Run the fix script (checked in at src/mongo/db/query/query_tester/tests/scripts/fix_regex_trailing_slash.py) against the repo to remove the trailing / from every "pattern" field value.
- Commit and open a PR on each corpus repo.
- After merge, bump the corresponding commit hash in src/mongo/db/query/query_tester/tests/test_repos.conf in 10gen/mongo.
Acceptance Criteria
- All query_correctness_generated_test_1/2/3 Evergreen tasks are green on an --//bazel/config:js_engine=wasm patch build.
- No changes to .test or .coll files — only .results files are affected.
- is related to
-
SERVER-116052 Add support for $function
-
- Closed
-
- related to
-
SERVER-125834 Remove trailing slashes from $function regex handling in query_tester-1
-
- Closed
-