-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Log error for invalid chatContext icon format instead of silently ignoring #288885
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
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
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
Adds validation to chatContext extension contributions so invalid icon strings no longer fail silently and instead produce a descriptive error in extension logs, improving debuggability for extension authors.
Changes:
- Parse
chatContextcontributioniconusingThemeIcon.fromString() - Log an error and skip the contribution when the icon string is present but unparsable
- Keep defensive skipping behavior for missing
icon(schema-violation edge case)
| const icon = contribution.icon ? ThemeIcon.fromString(contribution.icon) : undefined; | ||
| if (!icon && contribution.icon) { |
Copilot
AI
Jan 19, 2026
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.
The truthy check (contribution.icon ? ... : undefined and later if (!icon && contribution.icon)) will silently skip some invalid icon values like "" or null (both falsy), which defeats the goal of logging invalid formats. Consider checking specifically for property absence (e.g., contribution.icon === undefined) and validating typeof contribution.icon === 'string' before parsing so empty/invalid values still produce the error log.
| const icon = contribution.icon ? ThemeIcon.fromString(contribution.icon) : undefined; | |
| if (!icon && contribution.icon) { | |
| let icon: ThemeIcon | undefined; | |
| if (contribution.icon === undefined) { | |
| // Icon is required by schema, but handle defensively below | |
| } else if (typeof contribution.icon === 'string') { | |
| icon = ThemeIcon.fromString(contribution.icon); | |
| if (!icon) { | |
| ext.collector.error(localize('chatContextExtPoint.invalidIcon', "Invalid icon format for chat context contribution '{0}'. Icon must be in the format '$(iconId)' or '$(iconId~spin)', e.g. '$(copilot)'.", contribution.id)); | |
| continue; | |
| } | |
| } else { |
Invalid icon formats in
chatContextcontributions were silently ignored, making debugging difficult. For example,"icon": "copilot"instead of"icon": "$(copilot)"would cause the contribution to disappear without explanation.Changes
Added validation and error logging in
chatContext.contribution.ts:ThemeIcon.fromString()fails to parse a provided icon$(iconId)or$(iconId~spin)) with exampleErrors surface in extension development logs where extension authors expect validation feedback.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.