Skip to content

Strip parentheses before the futures and gRPC handlers match an argument - #2010

Merged
msridhar merged 2 commits into
uber:masterfrom
vlsi:handler-parens-futures-grpc
Oct 22, 2026
Merged

msridhar merged 2 commits into
uber:masterfrom
vlsi:handler-parens-futures-grpc

Conversation

@vlsi

@vlsi vlsi commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

A parenthesized argument hid a lambda from FluentFutureHandler and a Metadata.Key field from GrpcHandler, so both reported warnings that the same code without the parentheses does not. Futures.transform(in, (s -> { return null; }), e) reported returning @Nullable expression from method with @NonNull return type, and if (h.containsKey((K))) { take(h.get(K)); } reported passing @Nullable parameter 'h.get(K)' where @NonNull is required.

FluentFutureHandler now strips parentheses from each argument before comparing it with the enclosing lambda, and GrpcHandler strips them from the containsKey argument before resolving its symbol. A lambda nested deeper, such as an operand of a conditional passed to Futures.transform, is still not an argument of that call and still gets the Guava Function non-null return.

The other handlers need no change for parentheses: ContractHandler reads a boolean argument through ASTHelpers.constValue, which sees through the parentheses, StreamNullabilityPropagator, SynchronousCallbackHandler, and EnsuresNonNullIfHandler already strip them, and the remaining handlers read dataflow nodes, which carry no parentheses. The parentheses divergences in GenericsChecks (a parenthesized lambda assigned to a field, and a parenthesized map argument after filter(Objects::nonNull)) are outside the handlers and outside this change.

The new tests fail on master with the warnings above. Controls with the same parentheses still report: a lambda passed to a method outside the Futures APIs, a lambda inside a conditional, a lambda in a field initializer, and get of a key other than the one containsKey checked.

This is a variation of #1993.

Assisted-by: Claude Code (claude-opus-5-5)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved nullability analysis when keys in gRPC metadata lookups are wrapped in parentheses, while preserving diagnostics for lookups using a different key.
    • Improved recognition of parenthesized lambda arguments in Futures and FluentFuture transformations, with nullable-return diagnostics retained in contexts that require non-null values.
  • Tests

    • Added coverage for parenthesized gRPC metadata keys and future transformation lambdas, including cases where nullable results are accepted or diagnosed.

A parenthesized argument hid a lambda from `FluentFutureHandler` and a `Metadata.Key` field from `GrpcHandler`, so both reported warnings that the same code without the parentheses does not. `Futures.transform(in, (s -> { return null; }), e)` reported `returning @nullable expression from method with @nonnull return type`, and `if (h.containsKey((K))) { take(h.get(K)); }` reported `passing @nullable parameter 'h.get(K)' where @nonnull is required`.

`FluentFutureHandler` now strips parentheses from each argument before comparing it with the enclosing lambda, and `GrpcHandler` strips them from the `containsKey` argument before resolving its symbol. A lambda nested deeper, such as an operand of a conditional passed to `Futures.transform`, is still not an argument of that call and still gets the Guava `Function` non-null return.

The other handlers need no change for parentheses: `ContractHandler` reads a boolean argument through `ASTHelpers.constValue`, which sees through the parentheses, `StreamNullabilityPropagator`, `SynchronousCallbackHandler`, and `EnsuresNonNullIfHandler` already strip them, and the remaining handlers read dataflow nodes, which carry no parentheses. The parentheses divergences in `GenericsChecks` (a parenthesized lambda assigned to a field, and a parenthesized `map` argument after `filter(Objects::nonNull)`) are outside the handlers and outside this change.

The new tests fail on master with the warnings above. Controls with the same parentheses still report: a lambda passed to a method outside the Futures APIs, a lambda inside a conditional, a lambda in a field initializer, and `get` of a key other than the one `containsKey` checked.

This is a variation of uber#1993.

Assisted-by: Claude Code (claude-opus-5-5)
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: uber/NullAway/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d27fa82a-c04d-48cc-9066-53038ec5e0c1
📥 Commits

Reviewing files that changed from the base of the PR and between 7fdd018 and 3e15e27.

📒 Files selected for processing: 4
  • nullaway/src/main/java/com/uber/nullaway/handlers/GrpcHandler.java
  • nullaway/src/main/java/com/uber/nullaway/handlers/temporary/FluentFutureHandler.java
  • nullaway/src/test/java/com/uber/nullaway/FunctionalInterfaceNullabilityTests.java
  • nullaway/src/test/java/com/uber/nullaway/thirdpartylibs/GrpcTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

The gRPC handler now strips parentheses from the first containsKey argument before resolving its symbol. The FluentFuture handler strips parentheses from method arguments before checking whether they match the enclosing lambda. New tests cover parenthesized metadata keys and lambdas, including cases that expect nullable-return diagnostics.

Suggested reviewers: lazaroclapp

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3e15e

The parenthesized-argument changes appear ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely summarizes the main change: stripping parentheses before the futures and gRPC handlers match an argument.
Description check Passed The description is directly related to the changeset. It explains the affected handlers, the reported warnings, the implementation, the remaining control cases, and the added tests.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.76%. Comparing base (27f78a1) to head (3e15e27).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2010      +/-   ##
============================================
+ Coverage     88.74%   88.76%   +0.01%     
  Complexity       38       38              
============================================
  Files           118      118              
  Lines         12548    12551       +3     
  Branches       2543     2543              
============================================
+ Hits          11136    11141       +5     
+ Misses          643      642       -1     
+ Partials        769      768       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar
msridhar enabled auto-merge (squash) October 22, 2026 03:32
@msridhar
msridhar merged commit ad67857 into uber:master Oct 22, 2026
19 of 20 checks passed
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.

2 participants