Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Invalid icon formats in chatContext contributions 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:

  • Invalid format detection: Log descriptive error when ThemeIcon.fromString() fails to parse a provided icon
  • Error message: Explains required format ($(iconId) or $(iconId~spin)) with example
  • Defensive handling: Silently skip if icon property missing (schema violation edge case)
const icon = contribution.icon ? ThemeIcon.fromString(contribution.icon) : undefined;
if (!icon && contribution.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;
}

Errors surface in extension development logs where extension authors expect validation feedback.

Original prompt

This section details on the original issue you should resolve

<issue_title>Invalid 'icon' silently broke my contribution</issue_title>
<issue_description>Testing #280380

I initially had this

"chatContext": [{
      "id": "my-chat-context-provider",
      "displayName": "My Chat Context Provider",
      "icon": "copilot"
    }],

Because I forgot how the 'icon' should be formatted. I had to change it to $(copilot) in order for the entry to show up here:

Image

That's ok but I was looking for errors in the Window output channel. If a contribution is invalid and being ignored we should log an error.</issue_description>

<agent_instructions>This is for the API proposal for contributed chat contex.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 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.

Copilot AI and others added 3 commits January 19, 2026 12:53
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>
Copilot AI changed the title [WIP] Fix invalid icon logging for chat context contributions Log error for invalid chatContext icon format instead of silently ignoring Jan 19, 2026
Copilot AI requested a review from alexr00 January 19, 2026 13:00
@alexr00 alexr00 marked this pull request as ready for review January 19, 2026 13:24
Copilot AI review requested due to automatic review settings January 19, 2026 13:24
@alexr00 alexr00 enabled auto-merge (squash) January 19, 2026 13:24
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 19, 2026
Copy link
Contributor

Copilot AI left a 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 chatContext contribution icon using ThemeIcon.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)

Comment on lines 63 to +64
const icon = contribution.icon ? ThemeIcon.fromString(contribution.icon) : undefined;
if (!icon && contribution.icon) {
Copy link

Copilot AI Jan 19, 2026

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.

Suggested change
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 {

Copilot uses AI. Check for mistakes.
@alexr00 alexr00 merged commit afea1bf into main Jan 19, 2026
27 of 28 checks passed
@alexr00 alexr00 deleted the copilot/fix-invalid-icon-logging branch January 19, 2026 14:29
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.

Invalid 'icon' silently broke my contribution

3 participants