Skip to content

WQL queries with a multi-line WHERE clause are rejected with WqlSyntaxException #190

Description

@bertysentry

Found during the pre-release documentation review (#187).

Problem

A WQL query whose WHERE clause spans several lines is rejected locally with a WqlSyntaxException, although WMI accepts it. Such queries come naturally from Java text blocks or concatenations with \n:

client.wql("""
    SELECT Name FROM Win32_Service
    WHERE State = 'Running'
      AND StartMode = 'Auto'
    """).execute();   // WqlSyntaxException, nothing is sent

Checked against the current build (WmiHelper.isValidWql):

Query Accepted
SELECT Name FROM Win32_Service WHERE State = 'Running' AND StartMode = 'Auto' yes
SELECT Name FROM Win32_Service + \n + WHERE State = 'Running' yes
SELECT Name FROM Win32_Service + \n + WHERE State = 'Running' + \n + AND StartMode = 'Auto' no

Where

WmiHelper.WQL_SIMPLE_SELECT_PATTERN (src/main/java/org/metricshub/winrm/WmiHelper.java) ends with (WHERE\s+.*)?$ and is compiled with Pattern.CASE_INSENSITIVE only. Without Pattern.DOTALL, .* stops at the first line break, so $ cannot match. LightWinRMService.checkWqlArguments uses it for every query, so the legacy WinRMWqlExecutor is affected too.

Expected

Line breaks are accepted anywhere whitespace is, including inside the WHERE clause, probably by adding Pattern.DOTALL, without loosening the grammar otherwise. It stays a single SELECT of * or a property list, FROM one class, and an optional WHERE. ASSOCIATORS OF, REFERENCES OF and event queries stay rejected. Check the legacy WqlQuery parsing for the same issue, and add unit tests for the three cases above.

Activity

  1. self-assigned this
    on Sep 29, 2026
  2. added a commit that references this issue on Sep 29, 2026
    f8d164e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions