Validate user-facing query settings and enable featureFlagAllowUserFacingQuerySettings

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc1
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • QE 2026-07-06
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Overview

      Enable featureFlagAllowUserFacingQuerySettings so users can pass querySettings directly in find/aggregate/distinct commands as non-persisted runtime hints, and validate those user-supplied settings before applying them.

      Background

      User-supplied querySettings bypass the setQuerySettings command, which is where validation previously happened. Before the flag can be enabled, the same validation primitives must be applied to settings passed inline so that invalid settings (duplicate index hints, invalid key patterns, ungated queryKnobs) are rejected.

      Scope of Work

      * src/mongo/db/query/query_settings/query_settings_service.cpp — in both lookupQuerySettingsWithRejectionCheck overrides, validate user-supplied settings via the existing simplifyQuerySettings() + validateQuerySettings(), and reject ungated queryKnobs. Internal/forwarded (mongos to mongod) settings skip validation.
      * src/mongo/db/query/query_feature_flags.idl — flip featureFlagAllowUserFacingQuerySettings default to true.

      Acceptance Criteria

      * Invalid user-supplied querySettings (duplicate index hints, invalid index key patterns, ungated queryKnobs) are rejected with the same error codes as setQuerySettings.
      * Empty/default user-supplied querySettings on a query command are a no-op, not an error (unlike setQuerySettings).
      * Settings forwarded internally from mongos to mongod are not re-validated.
      * Unit and jstest coverage added.

      Technical Notes

      * The queryKnobs feature-flag guard is temporary; remove it once featureFlagPqsQueryKnobs is removed (SERVER-122103 / SPM-4364).

            Assignee:
            Denis Grebennicov
            Reporter:
            Denis Grebennicov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: