Skip to content

Refactor error definitions to eliminate duplicate helplink properties#808

Merged
cleemullins merged 5 commits intomainfrom
copilot/remove-duplicate-helplinks
Dec 3, 2025
Merged

Refactor error definitions to eliminate duplicate helplink properties#808
cleemullins merged 5 commits intomainfrom
copilot/remove-duplicate-helplinks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 2, 2025

Every error definition across all packages specified the same helplink pattern, duplicating 'https://aka.ms/M365AgentsErrorCodesJS/#{errorCode}' over 180 times.

Changes

  • Made helplink optional in AgentErrorDefinition - defaults to ExceptionHelper.DEFAULT_HELPLINK when omitted
  • Added DEFAULT_HELPLINK constant to ExceptionHelper class
  • Removed helplink from all error definitions - errors now inherit the default unless explicitly overridden
  • Updated tests to verify both default and override behavior

Example

Before:

InvalidActivityTypeUndefined: {
  code: -110000,
  description: 'Invalid ActivityType: undefined',
  helplink: 'https://aka.ms/M365AgentsErrorCodesJS/#{errorCode}'
}

After:

InvalidActivityTypeUndefined: {
  code: -110000,
  description: 'Invalid ActivityType: undefined'
}

Custom helplinks can still be specified when needed:

CustomError: {
  code: -999999,
  description: 'Special error',
  helplink: 'https://custom.example.com/error/{errorCode}'  // overrides default
}

The {errorCode} token replacement happens at exception generation time, producing URLs like https://aka.ms/M365AgentsErrorCodesJS/#-110000.

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove duplicated</issue_title>
<issue_description># Background
Each of the packages defined in this repo (agents-activity, agents-hosting, etc) has an "errorHelper.ts" file. An example of this file is here:
https://github.com/microsoft/Agents-for-js/blob/main/packages/agents-activity/src/errorHelper.ts

These all interact with the exceptionHelper class, found here:
https://github.com/microsoft/Agents-for-js/blob/main/packages/agents-activity/src/exceptionHelper.ts

Each of the many errors defined follow this general pattern:

  InvalidActivityTypeUndefined: {
    code: -110000,
    description: 'Invalid ActivityType: undefined',
    helplink: 'https://aka.ms/M365AgentsErrorCodesJS/#{errorCode}'
  },

The name, error code, and description are all unique to each error. The helplink is duplicated across All errors.

Ask

Refactor the code to eliminate all of these duplicate helpLink lines. The base class in exceptionHelper should have the value.

Must do: If a particular error wants to override the default by having a helplink property, that must be supported.

Once the code is done, write a simple suite of tests to validate:

  1. The default behavior
  2. The override behavior</issue_description>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 2, 2025 22:38
Co-authored-by: cleemullins <1165321+cleemullins@users.noreply.github.com>
- Made helplink optional in AgentErrorDefinition interface
- Added DEFAULT_HELPLINK constant in ExceptionHelper class
- Updated ExceptionHelper.generateException to use default when helplink not provided
- Added tests for default and override helplink behavior
- Removed all duplicate helplink properties from error definitions across all packages
- Updated existing tests to reflect optional helplink behavior

Co-authored-by: cleemullins <1165321+cleemullins@users.noreply.github.com>
Co-authored-by: cleemullins <1165321+cleemullins@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor errorHelper to eliminate duplicate helpLink lines Refactor error definitions to eliminate duplicate helplink properties Dec 2, 2025
Copilot AI requested a review from cleemullins December 2, 2025 22:53
@cleemullins cleemullins marked this pull request as ready for review December 2, 2025 22:57
Copilot AI review requested due to automatic review settings December 2, 2025 22:57
@cleemullins cleemullins enabled auto-merge (squash) December 2, 2025 22:57
Copy link
Copy Markdown
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

This PR successfully refactors the error handling system to eliminate ~180 duplicate helplink property declarations across all error definitions. The refactoring makes the helplink property optional in AgentErrorDefinition, with errors now inheriting a default help link pattern (https://aka.ms/M365AgentsErrorCodesJS/#{errorCode}) from the ExceptionHelper class when no custom help link is specified.

Key Changes:

  • Made helplink optional in the AgentErrorDefinition interface with proper TypeScript typing
  • Added DEFAULT_HELPLINK constant to the ExceptionHelper class using nullish coalescing for fallback behavior
  • Removed duplicate helplink properties from all error definitions across multiple packages while preserving the ability to override with custom help links
  • Added comprehensive test coverage validating both default and custom help link scenarios

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/agents-activity/src/exceptionHelper.ts Added DEFAULT_HELPLINK constant and made helplink optional in AgentErrorDefinition interface; implemented fallback logic using nullish coalescing operator
packages/agents-activity/src/errorHelper.ts Removed duplicate helplink properties from all 8 error definitions
packages/agents-activity/test/exceptionHelper.test.ts Added 3 new test cases validating default helplink behavior and custom helplink override capability
packages/agents-hosting/src/errorHelper.ts Removed duplicate helplink properties from all 75 error definitions
packages/agents-hosting/test/errorHelper.test.ts Updated test to reflect optional helplink with explanatory comment
packages/agents-hosting-storage-cosmos/src/errorHelper.ts Removed duplicate helplink properties from all 20 error definitions
packages/agents-hosting-storage-cosmos/test/errorHelper.test.ts Updated assertions to expect undefined helplink and removed token validation test in favor of default behavior verification
packages/agents-hosting-storage-blob/src/errorHelper.ts Removed duplicate helplink properties from all 3 error definitions
packages/agents-hosting-storage-blob/test/errorHelper.test.ts Updated test to reflect optional helplink with explanatory comment
packages/agents-hosting-extensions-teams/src/errorHelper.ts Removed duplicate helplink properties from all 19 error definitions
packages/agents-hosting-extensions-teams/test/errorHelper.test.ts Updated test to reflect optional helplink with explanatory comment
packages/agents-hosting-dialogs/src/errorHelper.ts Removed duplicate helplink properties from all 38 error definitions
packages/agents-hosting-dialogs/test/errorHelper.test.ts Updated test to reflect optional helplink with explanatory comment
.gitignore Removed generated line (appears unrelated to error refactoring)
package-lock.json Auto-generated npm dependency resolution updates marking various packages as peer dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cleemullins cleemullins merged commit a8d614f into main Dec 3, 2025
7 checks passed
@cleemullins cleemullins deleted the copilot/remove-duplicate-helplinks branch December 3, 2025 18:11
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.

Remove duplicated helplink attribute across errorHelper classes

4 participants