Skip to content

fix: address CodeQL formatting warnings - #19826

Open
FrankChen021 wants to merge 3 commits into
apache:masterfrom
FrankChen021:codex/codeql-warning-formatting
Open

fix: address CodeQL formatting warnings#19826
FrankChen021 wants to merge 3 commits into
apache:masterfrom
FrankChen021:codex/codeql-warning-formatting

Conversation

@FrankChen021

@FrankChen021 FrankChen021 commented Jul 30, 2026

Copy link
Copy Markdown
Member

What

  • fix all six format calls that supplied unused arguments
  • preserve IOException causes in ForkingTaskRunner
  • move 12 SQL lexer actions into JavaCC's common-token hook
  • keep generated lexer behavior unchanged while avoiding misleading generated indentation

Why

This group contains 20 CodeQL warnings:

  • 6 java/unused-format-argument
  • 14 java/misleading-indentation

This 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

  • affected-module compilation and Checkstyle passed
  • formatting-focused tests: 47 passed
  • SQL parser/unparser tests: 23 passed
  • committed DruidSqlParserImplTokenManagerTest: 4 passed, covering every moved before/after-table-name action, hyphenated-identifier state restoration, comment interaction, and end-to-end BigQuery parsing
  • JaCoCo for generated CommonTokenAction: 8/8 lines and 4/4 branches; beforeTableName, afterTableName, pushState, and popState each have full line coverage
  • original and generated common-token lexers matched in 12/12 targeted scenarios
  • parser regeneration completed with zero errors
  • git diff --check

Created by GPT-5.6-Sol.

@github-actions github-actions Bot added Area - Batch Ingestion Area - Querying Area - Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Jul 30, 2026
@FrankChen021
FrankChen021 marked this pull request as ready for review July 30, 2026 21:25
Copilot AI review requested due to automatic review settings July 30, 2026 21:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.getNextAttemptID error reporting to include the directory path and preserve IOException causes; added targeted regression tests.
  • Enabled COMMON_TOKEN_ACTION in 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 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Batch Ingestion Area - Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants