Skip to content

java: enforce non-blank @CopilotToolParam description at compile time#1980

Merged
edburns merged 2 commits into
github:mainfrom
rinceyuan:feat/java-blank-param-validation
Jul 23, 2026
Merged

java: enforce non-blank @CopilotToolParam description at compile time#1980
edburns merged 2 commits into
github:mainfrom
rinceyuan:feat/java-blank-param-validation

Conversation

@rinceyuan

Copy link
Copy Markdown
Contributor

Closes #1836

Summary

Adds compile-time validation in CopilotToolProcessor to reject @CopilotToolParam annotations with blank value() (description). Without a meaningful description, the LLM cannot reliably select and invoke tools.

Changes

CopilotToolProcessor.java

  • Added blank-description check after the single-record wrapper validation block
  • Checks paramAnnotation.value().isBlank() (catches both empty and whitespace-only)
  • Single-record wrapper parameters are exempt (as specified in the issue)
  • Error message identifies the parameter name, enclosing method, and class

CopilotToolProcessorTest.java (5 new tests)

  1. Blank value@CopilotToolParam("") produces compile error
  2. Whitespace-only value@CopilotToolParam(" ") produces compile error
  3. Valid value@CopilotToolParam("Search query") compiles without error
  4. No annotation — unannotated parameter compiles without error
  5. Record wrapper exemption@CopilotToolParam on single-record wrapper is exempt

Error message example

error: @CopilotToolParam on parameter 'query' in 'BlankDescTools.searchItems' has a blank value (description).
Descriptions are required so the LLM can correctly select and invoke the tool

Testing

  • mvn test -Dtest=CopilotToolProcessorTest — 39 tests pass (0 failures)
  • All existing tests pass with no regressions
  • Local JDK is 17; CI will run the full mvn verify with JDK 25+

Closes github#1836

Add compile-time validation in CopilotToolProcessor to reject
@CopilotToolParam annotations with blank value (description).

- Blank or whitespace-only descriptions now produce a compile error
- Single-record wrapper parameters are exempt (they delegate to
  record component annotations)
- Error message identifies parameter name, method, and class
- 5 new tests covering blank, whitespace, valid, unannotated, and
  record-wrapper cases
@rinceyuan
rinceyuan requested a review from a team as a code owner July 14, 2026 08:30
@rinceyuan

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company=Microsoft

@rinceyuan

Copy link
Copy Markdown
Contributor Author

@edburns Hi! This implements #1836 — compile-time validation for blank @CopilotToolParam descriptions in the annotation processor. 5 new tests, all passing. Would appreciate your review. Thanks!

@rinceyuan

Copy link
Copy Markdown
Contributor Author

@stephentoub Gentle ping — this implements the spec from #1836 (blank @CopilotToolParam description validation). 2 files, 5 new tests, all passing. Happy to address any feedback!

@rinceyuan

Copy link
Copy Markdown
Contributor Author

@edburns @stephentoub Friendly follow-up — this PR has been open for 6 days with no review. It's a small change (18 lines in the processor + 5 tests) implementing the spec from #1836. Happy to rebase or address any concerns. Is there anything blocking review?

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

Adds compile-time enforcement for non-blank @CopilotToolParam descriptions while exempting record-wrapper parameters.

Changes:

  • Validates empty and whitespace-only descriptions with contextual errors.
  • Adds tests for invalid, valid, unannotated, and exempt parameters.
Show a summary per file
File Description
CopilotToolProcessor.java Implements description validation.
CopilotToolProcessorTest.java Covers validation and exemption behavior.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@edburns

edburns commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

CI Failure Analysis

The CI failure in this run is unrelated to this PR's changes.

Root cause

CopilotSessionTest.testShouldAbortSession timed out after 60s — a flaky E2E test with no connection to the tool processor validation added here.

Local verification

  • mvn spotless:apply — no formatting changes needed (307 files already clean)
  • ✅ All 5 new tests pass locally (blank param description validation)
  • ✅ Checkstyle: 0 violations
  • ✅ Compilation succeeds on JDK 25

Recommendation

Re-run CI — the timeout is transient and not caused by this PR.

@edburns
edburns enabled auto-merge July 23, 2026 13:38
@edburns
edburns added this pull request to the merge queue Jul 23, 2026
Merged via the queue into github:main with commit 949de90 Jul 23, 2026
23 of 24 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.

[Java] @CopilotTool ergonomics: Enforce non-blank @Param description at compile time

3 participants