Skip to content

Accept multi-line WHERE clauses in WQL queries - #192

Merged
bertysentry merged 1 commit into
mainfrom
190-wql-queries-with-a-multi-line-where-clause-are-rejected-with-wqlsyntaxexception
Sep 29, 2026
Merged

bertysentry merged 1 commit into
mainfrom
190-wql-queries-with-a-multi-line-where-clause-are-rejected-with-wqlsyntaxexception

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Fixes #190.

WmiHelper.WQL_SIMPLE_SELECT_PATTERN was compiled with CASE_INSENSITIVE only, so the .* of the optional WHERE group stopped at the first line break and a query such as

client.wql("""
    SELECT Name FROM Win32_Service
    WHERE State = 'Running'
      AND StartMode = 'Auto'
    """).execute();

was rejected with WqlSyntaxException before anything was sent. Adding Pattern.DOTALL lets line breaks appear wherever whitespace is, without loosening the grammar otherwise: ASSOCIATORS OF, REFERENCES OF, event queries and multiple SELECTs are still rejected.

The legacy WqlQuery pattern already used DOTALL, so it is unaffected.

  • WmiHelperTest covers the three cases from the issue (plus CRLF) and the rejections; the multi-line case fails without the fix.
  • wql.md notes that line breaks are accepted, so text blocks work as is.

🤖 Generated with Claude Code

WmiHelper.WQL_SIMPLE_SELECT_PATTERN was compiled without Pattern.DOTALL,
so `.*` in the optional WHERE group stopped at the first line break and
queries written as text blocks were rejected with WqlSyntaxException.
The legacy WqlQuery pattern already had DOTALL and is unaffected.

Fixes #190

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T20:00:01.593057Z f8d164e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8d164e716

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/org/metricshub/winrm/WmiHelper.java
@bertysentry
bertysentry merged commit 1bf71dc into main Sep 29, 2026
5 checks passed
@bertysentry
bertysentry deleted the 190-wql-queries-with-a-multi-line-where-clause-are-rejected-with-wqlsyntaxexception branch September 29, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant