-
Notifications
You must be signed in to change notification settings - Fork 36
Add JSON Schema conditionals for command trigger conflicts with improved error messages #2979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Added allOf conditional to main_workflow_schema.json to enforce that command triggers cannot be used with issues, issue_comment, pull_request, or pull_request_review_comment events - Added comprehensive test cases in schema_test.go to validate both invalid and valid command trigger configurations - Updated compiler_test.go to expect schema validation errors instead of compiler errors - Verified schema validation catches conflicts before compilation Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot improve the error message |
- Added custom validation with clear, helpful error messages - Moved command conflict validation before schema validation - Error messages now explain why the conflict exists and what command triggers are for - Removed unsupported errorMessage field from schema - Updated test expectations to match new error messages Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Improved error message in commit 1df047e. Before: After: The error message now:
|
There was a problem hiding this 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 improves error messaging for command trigger validation by adding custom validation and updating error messages to be more descriptive. The changes ensure that when a command trigger is used with conflicting events (issues, issue_comment, pull_request, pull_request_review_comment), users receive clear, helpful error messages explaining why the combination is invalid.
Key changes:
- Added custom validation function
validateCommandTriggerConflictsthat runs before JSON schema validation to provide clearer error messages - Updated test expectations to match the new, more descriptive error messages
- Added comprehensive test coverage for command trigger conflict scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/parser/schema.go | Added validateCommandTriggerConflicts function and integrated it into the validation pipeline to provide better error messages for command trigger conflicts |
| pkg/parser/schema_test.go | Added test cases covering various command trigger conflict scenarios and valid command trigger usage patterns |
| pkg/parser/schemas/main_workflow_schema.json | Added JSON schema validation rules using allOf/if-then to enforce command trigger conflict constraints at the schema level |
| pkg/workflow/compiler_test.go | Updated expected error messages in existing tests to match the new, more descriptive error format |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The compiler enforced command trigger conflicts at runtime (
compiler.go:1221), but the schema didn't validate them. This moves validation to parse time using JSON Schema conditionals and adds custom validation with clear, helpful error messages.Changes
Schema (
main_workflow_schema.json): AddedallOfconstraint usingif/then/notpattern to reject command triggers combined withissues,issue_comment,pull_request, orpull_request_review_commenteventsCustom validation (
schema.go): AddedvalidateCommandTriggerConflictsfunction that runs before schema validation to provide clear, helpful error messages explaining why the conflict existsParser tests (
schema_test.go): Added 9 test cases covering invalid conflicts and valid combinationsCompiler tests (
compiler_test.go): Updated error expectations to match new custom validation error messagesError Messages
Previously, generic schema errors were shown:
Now, clear and helpful messages explain the conflict:
For multiple conflicts:
Example
Previously accepted at parse time, caught at compile time:
Now rejected at parse time with a clear error message.
Valid combinations still work:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.