java: enforce non-blank @CopilotToolParam description at compile time#1980
Conversation
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
|
@microsoft-github-policy-service agree company=Microsoft |
|
@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! |
|
@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? |
There was a problem hiding this comment.
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
CI Failure AnalysisThe CI failure in this run is unrelated to this PR's changes. Root cause
Local verification
RecommendationRe-run CI — the timeout is transient and not caused by this PR. |
Closes #1836
Summary
Adds compile-time validation in
CopilotToolProcessorto reject@CopilotToolParamannotations with blankvalue()(description). Without a meaningful description, the LLM cannot reliably select and invoke tools.Changes
CopilotToolProcessor.javaparamAnnotation.value().isBlank()(catches both empty and whitespace-only)CopilotToolProcessorTest.java(5 new tests)@CopilotToolParam("")produces compile error@CopilotToolParam(" ")produces compile error@CopilotToolParam("Search query")compiles without error@CopilotToolParamon single-record wrapper is exemptError message example
Testing
mvn test -Dtest=CopilotToolProcessorTest— 39 tests pass (0 failures)mvn verifywith JDK 25+