Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

  • Understand the issue: NullPointerException occurs when ctx.children is null in sufficientSize method
  • Fix using getChildCount() method instead of direct field access (per reviewer suggestion)
  • Run existing tests to validate the fix (all 4 tests passed)
  • Run code review
  • Run codeql checker (no security alerts)
Original prompt

This section details on the original issue you should resolve

<issue_title>NullPointerException: Cannot invoke "java.util.List.size()" because "ctx.children" is null</issue_title>
<issue_description>Sentry Issue: BSL-LANGUAGE-SERVER-MP

NullPointerException: Cannot invoke "java.util.List.size()" because "ctx.children" is null
    at com.github._1c_syntax.bsl.languageserver.diagnostics.IdenticalExpressionsDiagnostic.sufficientSize(IdenticalExpressionsDiagnostic.java:238)
    at com.github._1c_syntax.bsl.languageserver.diagnostics.IdenticalExpressionsDiagnostic.onExpressionEnter(IdenticalExpressionsDiagnostic.java:99)
    at com.github._1c_syntax.bsl.languageserver.diagnostics.AbstractExpressionTreeDiagnostic$ExpressionTreeBuilder.visitExpression(AbstractExpressionTreeDiagnostic.java:101)
    at com.github._1c_syntax.bsl.languageserver.diagnostics.AbstractExpressionTreeDiagnostic$ExpressionTreeBuilder.visitExpression(AbstractExpressionTreeDiagnostic.java:94)
    at com.github._1c_syntax.bsl.parser.BSLParser$ExpressionContext.accept(BSLParser.java:6697)
...
(56 additional frame(s) were not displayed)
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Comment @coderabbitai help to get the list of available commands and usage tips.

@nixel2007
Copy link
Member

Copilot AI changed the title [WIP] Fix NullPointerException for ctx.children being null Fix NPE in IdenticalExpressionsDiagnostic when ctx.children is null Dec 18, 2025
Copilot AI requested a review from nixel2007 December 18, 2025 13:33
@nixel2007 nixel2007 marked this pull request as ready for review December 18, 2025 13:42
Copilot AI review requested due to automatic review settings December 18, 2025 13:42
@nixel2007 nixel2007 enabled auto-merge December 18, 2025 13:42
@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

Test Results

2 700 files  ±0  2 700 suites  ±0   49m 11s ⏱️ +39s
1 013 tests ±0  1 013 ✅ ±0  0 💤 ±0  0 ❌ ±0 
9 117 runs  ±0  9 117 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 0db3439. ± Comparison against base commit 963574c.

♻️ This comment has been updated with latest results.

Copy link
Contributor

Copilot AI left a comment

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 fixes a NullPointerException in IdenticalExpressionsDiagnostic that occurs when ctx.children is null. The fix replaces direct field access (ctx.children.size()) with the ANTLR-provided method (ctx.getChildCount()), which handles null cases properly.

Key Changes

  • Modified the sufficientSize() method to use getChildCount() instead of direct field access
  • The change prevents NPE when processing expressions with null children

@nixel2007 nixel2007 disabled auto-merge December 18, 2025 20:10
@nixel2007 nixel2007 merged commit ce91ab5 into develop Dec 18, 2025
47 of 48 checks passed
@nixel2007 nixel2007 deleted the copilot/fix-nullpointerexception-ctx-children branch December 18, 2025 20:10
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.

NullPointerException: Cannot invoke "java.util.List.size()" because "ctx.children" is null

2 participants