fix: address CodeQL formatting warnings - #19826
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses CodeQL findings in Apache Druid by fixing unused format-argument call sites, improving exception messages to preserve causes/values, and reducing misleading-indentation warnings in the generated SQL lexer by moving lexer actions into JavaCC’s COMMON_TOKEN_ACTION hook while keeping lexer behavior consistent.
Changes:
- Updated format strings to match Druid’s
StringUtils.nonStrictFormat-style formatting and avoid unused arguments. - Improved
ForkingTaskRunner.getNextAttemptIDerror reporting to include the directory path and preserveIOExceptioncauses; added targeted regression tests. - Enabled
COMMON_TOKEN_ACTIONin the SQL JavaCC grammar and centralized token-driven lexer state transitions; added a new token-manager test for key BigQuery lexer behaviors.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sql/src/test/java/org/apache/druid/sql/calcite/parser/DruidSqlParserImplTokenManagerTest.java | Adds focused tests validating BigQuery lexer state transitions and special-token behavior after moving actions to CommonTokenAction. |
| sql/src/main/codegen/templates/Parser.jj | Enables COMMON_TOKEN_ACTION and moves table-name / hyphenated-identifier lexer actions into CommonTokenAction to avoid misleading-indentation in generated code. |
| server/src/test/java/org/apache/druid/server/log/DefaultRequestLogEventTest.java | Fixes an unused format argument by adding a %s placeholder for the timestamp in the expected JSON string. |
| multi-stage-query/src/test/java/org/apache/druid/msq/test/MSQTestOverlordServiceClient.java | Fixes unused formatting argument by switching from {} to [%s] in a defensive exception message. |
| indexing-service/src/test/java/org/apache/druid/indexing/overlord/ForkingTaskRunnerTest.java | Adds regression tests ensuring getNextAttemptID failures preserve IOException causes and include the relevant path in the message. |
| indexing-service/src/test/java/org/apache/druid/indexing/common/task/FilteringCloseableInputRowIteratorTest.java | Fixes unused formatting arguments in ParseException construction by adding [%d] placeholders. |
| indexing-service/src/main/java/org/apache/druid/indexing/overlord/ForkingTaskRunner.java | Preserves causes and includes the directory path in ISE messages when attempt directories cannot be created. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
FrankChen021
left a comment
There was a problem hiding this comment.
I have reviewed the code for correctness, edge cases, concurrency, and integration risks; no issues found.
Reviewed 7 of 7 changed files.
This is an automated review by Codex GPT-5.6-Sol
What
IOExceptioncauses inForkingTaskRunnerWhy
This group contains 20 CodeQL warnings:
java/unused-format-argumentjava/misleading-indentationThis PR directly addresses all six format warnings and 12 of the 14 generated indentation warnings.
Generator limitation
The remaining two warnings are emitted by JavaCC 4.0's own
getNextToken()template around lexical-state transitions. They cannot be changed from Druid's grammar. Upgrading to JavaCC 7.0.13 was evaluated, but it produced a large generated diff, compilation incompatibilities, and parser error-message behavior changes while retaining these two sites.Impact
Exceptions now include the intended causes and values. SQL lexer state transitions retain the same token images, kinds, special-token chains, and resulting states.
Checks
DruidSqlParserImplTokenManagerTest: 4 passed, covering every moved before/after-table-name action, hyphenated-identifier state restoration, comment interaction, and end-to-end BigQuery parsingCommonTokenAction: 8/8 lines and 4/4 branches;beforeTableName,afterTableName,pushState, andpopStateeach have full line coveragegit diff --checkCreated by GPT-5.6-Sol.