Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f1a2550
Initial plan
Copilot Nov 14, 2025
5639b46
Extract error codes from CosmosDB to errorHelper.ts
Copilot Nov 14, 2025
1f89bf7
Add unit tests for errorHelper
Copilot Nov 14, 2025
9b65b70
Merge branch 'main' into copilot/extract-error-codes-cosmosdb
cleemullins Nov 14, 2025
081fcf0
Update packages/agents-hosting-storage-cosmos/src/errorHelper.ts
cleemullins Nov 14, 2025
ff451e4
Update packages/agents-hosting-storage-cosmos/src/cosmosDbPartitioned…
cleemullins Nov 14, 2025
21ce4f6
Update packages/agents-hosting-storage-cosmos/src/cosmosDbPartitioned…
cleemullins Nov 14, 2025
6b70c5b
Update packages/agents-hosting-storage-cosmos/src/errorHelper.ts
cleemullins Nov 14, 2025
dece2bb
Refactor error handling to use ExceptionHelper consistently and fix i…
Copilot Nov 14, 2025
6a37afe
Merge branch 'main' into copilot/extract-error-codes-cosmosdb
cleemullins Nov 17, 2025
0ddc0d5
Merge branch 'main' into copilot/extract-error-codes-cosmosdb
cleemullins Nov 18, 2025
f02fde1
Move ExceptionHelper to agents-activity package and refactor AgentErr…
Copilot Nov 18, 2025
e0406d6
Refactor ErrorHelper class to Errors const object
Copilot Nov 18, 2025
ab57c72
Change ExceptionHelper to use named parameters object instead of arra…
Copilot Nov 18, 2025
e173c1e
revert changes to tsconfig. add ts-expect-error in test for undefined…
benbrown Nov 19, 2025
0b83fad
Add AgentError interface to eliminate TypeScript warnings on custom e…
Copilot Nov 19, 2025
97bfdee
Format exception message as [CODE] - [message] - [helplink]
Copilot Nov 19, 2025
df76e61
Refactor to use tokenized {errorCode} in helplinks to avoid duplication
Copilot Nov 19, 2025
25eb946
Initial plan
Copilot Nov 19, 2025
8ed1f18
Improve error message quality in errorHelper.ts
Copilot Nov 19, 2025
680ce55
Merge branch 'main' into copilot/improve-error-messages-quality
cleemullins Nov 19, 2025
deb5ffe
Update packages/agents-hosting-storage-cosmos/src/errorHelper.ts
cleemullins Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions packages/agents-hosting-storage-cosmos/src/errorHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingCosmosDbStorageOptions: {
code: -100000,
description: 'CosmosDbPartitionedStorageOptions is required.',
description: 'CosmosDbPartitionedStorageOptions is required. Provide a valid configuration object with cosmosClientOptions, databaseId, and containerId properties when initializing CosmosDbPartitionedStorage.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -33,7 +33,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingCosmosEndpoint: {
code: -100001,
description: 'endpoint in cosmosClientOptions is required.',
description: 'The endpoint property in cosmosClientOptions is required. Provide your Cosmos DB account endpoint URL (e.g., https://your-account.documents.azure.com:443/).',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -42,7 +42,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingCosmosCredentials: {
code: -100002,
description: 'key or tokenProvider in cosmosClientOptions is required.',
description: 'Authentication credentials are required in cosmosClientOptions. Provide either a key (connection key) or tokenProvider (for token-based authentication).',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -51,7 +51,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingDatabaseId: {
code: -100003,
description: 'databaseId for CosmosDB is required.',
description: 'The databaseId property is required in CosmosDbPartitionedStorageOptions. Specify the name of the Cosmos DB database to use for storage.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -60,7 +60,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingContainerId: {
code: -100004,
description: 'containerId for CosmosDB is required.',
description: 'The containerId property is required in CosmosDbPartitionedStorageOptions. Specify the name of the Cosmos DB container to use for storage.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -69,7 +69,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
InvalidCompatibilityModeWithKeySuffix: {
code: -100005,
description: 'compatibilityMode cannot be true while using a keySuffix.',
description: 'Configuration conflict: compatibilityMode cannot be enabled (true) when using a keySuffix. Either disable compatibilityMode or remove the keySuffix from your configuration.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -78,7 +78,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
InvalidKeySuffixCharacters: {
code: -100006,
description: 'Cannot use invalid Row Key characters: {keySuffix} in keySuffix',
description: 'The keySuffix "{keySuffix}" contains invalid characters. Keys cannot contain: \\, ?, /, #, tab, newline, carriage return, or *. Please remove these characters from your keySuffix configuration.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -87,7 +87,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingReadKeys: {
code: -100007,
description: 'Keys are required when reading.',
description: 'The keys parameter is required when calling read(). Provide an array of storage keys to read.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -96,7 +96,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingWriteChanges: {
code: -100008,
description: 'Changes are required when writing.',
description: 'The changes parameter is required when calling write(). Provide a StoreItems object containing the data to write.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -105,7 +105,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
UnsupportedCustomPartitionKeyPath: {
code: -100009,
description: 'Custom Partition Key Paths are not supported. {containerId} has a custom Partition Key Path of {partitionKeyPath}.',
description: 'The container "{containerId}" uses a custom partition key path "{partitionKeyPath}", which is not supported. This storage implementation requires containers to use either "/id" as the partition key path or no partition key (for compatibility mode). Create a new container with the correct partition key configuration.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -114,7 +114,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
ContainerNotFound: {
code: -100010,
description: 'Container {containerId} not found.',
description: 'The Cosmos DB container "{containerId}" was not found and could not be created. Verify the container exists or ensure the client has permissions to create it. If using compatibilityMode, the container must already exist.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -123,7 +123,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MissingKeyParameter: {
code: -100011,
description: "The 'key' parameter is required.",
description: 'The key parameter is required and cannot be null or empty. Provide a valid storage key string.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -132,7 +132,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
ContainerReadNotFound: {
code: -100012,
description: 'Not Found',
description: 'The requested item was not found in the Cosmos DB container. This is typically not an error during read operations.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -141,7 +141,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
ContainerReadBadRequest: {
code: -100013,
description: 'Error reading from container. You might be attempting to read from a non-partitioned container or a container that does not use \'/id\' as the partitionKeyPath',
description: 'Bad request error while reading from the Cosmos DB container. This usually indicates a configuration mismatch: the container may be non-partitioned or uses a partition key path other than "/id". Verify your container\'s partition key configuration matches the storage implementation requirements.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -150,7 +150,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
ContainerReadError: {
code: -100014,
description: 'Error reading from container',
description: 'An unexpected error occurred while reading from the Cosmos DB container. Check the inner exception for details about the specific error.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -159,7 +159,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
DocumentUpsertError: {
code: -100015,
description: 'Error upserting document',
description: 'Failed to upsert (insert or update) a document in the Cosmos DB container. This may be due to concurrency conflicts, permission issues, or data size limits. Check the inner exception for specific details.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -168,7 +168,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
DocumentDeleteNotFound: {
code: -100016,
description: 'Not Found',
description: 'The document to delete was not found in the Cosmos DB container. This is typically not an error during delete operations.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -177,7 +177,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
DocumentDeleteError: {
code: -100017,
description: 'Unable to delete document',
description: 'Failed to delete a document from the Cosmos DB container. This may be due to permission issues or network problems. Check the inner exception for specific details.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -186,7 +186,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
InitializationError: {
code: -100018,
description: 'Failed to initialize Cosmos DB database/container: {databaseId}/{containerId}',
description: 'Failed to initialize the Cosmos DB database "{databaseId}" and container "{containerId}". Verify your connection credentials, ensure the account exists, and check that the client has appropriate permissions. See the inner exception for specific error details.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
},

Expand All @@ -195,7 +195,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
*/
MaxNestingDepthExceeded: {
code: -100019,
description: 'Maximum nesting depth of {maxDepth} exceeded. {additionalMessage}',
description: 'The data structure exceeds the maximum nesting depth of {maxDepth} levels. {additionalMessage} This limit is imposed to prevent stack overflow errors when storing deeply nested objects in Cosmos DB.',
helplink: 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ describe('Errors tests', () => {
const error = Errors.MissingCosmosDbStorageOptions

assert.strictEqual(error.code, -100000)
assert.strictEqual(error.description, 'CosmosDbPartitionedStorageOptions is required.')
assert.strictEqual(error.description, 'CosmosDbPartitionedStorageOptions is required. Provide a valid configuration object with cosmosClientOptions, databaseId, and containerId properties when initializing CosmosDbPartitionedStorage.')
assert.strictEqual(error.helplink, 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}')
})

it('should have MissingCosmosEndpoint error definition', () => {
const error = Errors.MissingCosmosEndpoint

assert.strictEqual(error.code, -100001)
assert.strictEqual(error.description, 'endpoint in cosmosClientOptions is required.')
assert.strictEqual(error.description, 'The endpoint property in cosmosClientOptions is required. Provide your Cosmos DB account endpoint URL (e.g., https://your-account.documents.azure.com:443/).')
assert.strictEqual(error.helplink, 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}')
})

it('should have MissingCosmosCredentials error definition', () => {
const error = Errors.MissingCosmosCredentials

assert.strictEqual(error.code, -100002)
assert.strictEqual(error.description, 'key or tokenProvider in cosmosClientOptions is required.')
assert.strictEqual(error.description, 'Authentication credentials are required in cosmosClientOptions. Provide either a key (connection key) or tokenProvider (for token-based authentication).')
assert.strictEqual(error.helplink, 'https://aka.ms/M365AgentsErrorCodes/#{errorCode}')
})

Expand Down
Loading