MLE-28335 added fragment option in fromSearch#1077
Open
RitaChen609 wants to merge 4 commits into
Open
Conversation
- Add 'fragment' option support to fromSearch() for MLS 12.1+ - Valid values: 'document' (default), 'properties', 'locks', 'any' - Client-side validation in PlanSearchOption (plan-builder-base.js) - Updated JSDoc for fromSearch() in plan-builder-generated.js - Added xdmp-lock-acquire/release privileges to rest-evaluator role in both test-setup-users.js and rest-evaluator.json (Gradle config) - Added fragment option integration tests to test-basic/plan-search.js (TC0-TC5, gated on serverVersion >= 12.1)
There was a problem hiding this comment.
Pull request overview
Adds support for the new fragment option in fromSearch() (introduced in MLS 12.1), along with client-side validation, JSDoc updates, and integration tests. Also grants the rest-evaluator role the xdmp-lock-acquire/xdmp-lock-release execute privileges required by the new lock-based test setup.
Changes:
- Validate the new
'fragment'key (allowed values:'document','properties','locks','any') in thePlanSearchOptionbranch ofcastArg, and document it in thefromSearch()JSDoc. - Add an integration test suite (TC0–TC5) covering default behavior, invalid-value validation, all four fragment values, and
explain()round-trip — gated onserverVersion >= 12.1. - Add
xdmp-lock-acquire/xdmp-lock-releaseexecute privileges to therest-evaluatorrole in both the Gradle config and the JS-based test setup.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/plan-builder-base.js |
Adds fragment case to PlanSearchOption validation switch. |
lib/plan-builder-generated.js |
Updates fromSearch() JSDoc to document the new fragment key and pre-12.1 behavior. |
test-basic/plan-search.js |
Adds new describe block with TC0–TC5 tests, gated on server version, with lock setup/teardown. |
etc/test-setup-users.js |
Adds lock-acquire/release privileges to the JS-created rest-evaluator role. |
test-app/src/main/ml-config/security/roles/rest-evaluator.json |
Same lock privileges added to the Gradle-deployed role definition. |
Security fixes: - sanitize-html: 2.17.0 → ^2.17.4 (critical XSS via xmp passthrough, GHSA-rpr9-rxv7-x643) - brace-expansion override: 2.0.2 → 5.0.6 (DoS via zero-step sequence, GHSA-f886-m6hf-6m8v) - serialize-javascript override: 7.0.4 → 7.0.5 (CPU exhaustion DoS, GHSA-qj8w-gfj5-8c6v) - diff override: added 9.0.0 (DoS in parsePatch/applyPatch for mocha 11.4+, GHSA-73rr-hh4g-fpgx) - fast-uri, flatted, lodash, picomatch, postcss updated via npm audit fix
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.
Summary
What changed and why:
Added support for the new
fragmentoption infromSearch(), introduced in MLS 12.1 (MLE-27802). This option controls which document fragment type is searched by the Optic API.Valid values:
'document'(default),'properties','locks','any'On servers earlier than MLS 12.1, the option is silently ignored and all fragment types are searched.
Files/paths touched:
lib/plan-builder-base.jsfragmentkey validation toPlanSearchOptioncase incastArgswitchlib/plan-builder-generated.js@param optionJSDoc forfromSearch()to documentfragmentkey and MLS 12.1 version notetest-basic/plan-search.jsdescribe('fragment option tests for fromSearch')with TC0–TC5, gated onserverVersion >= 12.1etc/test-setup-users.jsxdmp-lock-acquireandxdmp-lock-releaseexecute privileges torest-evaluatorroletest-app/src/main/ml-config/security/roles/rest-evaluator.jsonEvidence
Test command:
npx mocha test-basic/plan-search.js --grep "fragment option"Output:
Coverage: 8 new integration tests covering all 4 valid fragment values, the default (no-option) behavior, client-side validation of invalid values, and explain() round-trip on a locks plan.
Risk & Rollback
fragmentkey is a new optional parameter. Thedefault: return falsein thePlanSearchOptionswitch already handles unknown keys.git revert d325837Review Focus
lib/plan-builder-base.js(~line 139): The newfragmentcase in thePlanSearchOptionswitch — confirm the allowed values match the MLS 12.1 server-side contract.lib/plan-builder-generated.js(~line 9015): JSDoc wording for thefragmentkey and the note about pre-12.1 behavior.test-basic/plan-search.js: Thebefore()/after()hooks use two sequentialxqueryEvalcalls (release locks, then delete docs) — this is intentional to avoidXDMP-CONFLICTINGUPDATES.rest-evaluator.json: Thexdmp-lock-acquire/xdmp-lock-releaseprivileges are required for non-admin users running the testbefore()/after()hooks viaxqueryEval.Verification steps: