Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(errors): set this.name on three ComposioError subclasses

Rohitc0f16093ed46
diff --git a/.changeset/fix-error-subclass-names.md b/.changeset/fix-error-subclass-names.md
new file mode 100644
index 000000000..860e3a256
--- /dev/null
+++ b/.changeset/fix-error-subclass-names.md
@@ -0,0 +1,5 @@
+---
+'@composio/core': patch
+---
+
+Fix three ComposioError subclasses (ComposioToolVersionRequiredError, JsonSchemaToZodError, JsonSchemaRefResolutionError) that omitted their `this.name` assignment and therefore reported `name` as 'ComposioError' instead of their own class name, mis-grouping distinct error types in error telemetry.
diff --git a/ts/packages/core/src/errors/ToolErrors.ts b/ts/packages/core/src/errors/ToolErrors.ts
index 45c0e398b..eb4da56d2 100644
--- a/ts/packages/core/src/errors/ToolErrors.ts
+++ b/ts/packages/core/src/errors/ToolErrors.ts
@@ -204,6 +204,7 @@ export class ComposioToolVersionRequiredError extends ComposioError {
'Set dangerouslySkipVersionCheck to true (this might cause unexpected behavior when new versions of the tools are released)',
],
});
+ this.name = 'ComposioToolVersionRequiredError';
}
}
export interface ComposioAPIServerErrorBody {
diff --git a/ts/packages/core/src/errors/ValidationErrors.ts b/ts/packages/core/src/errors/ValidationErrors.ts
index ad62d7577..094c3898e 100644
--- a/ts/packages/core/src/errors/ValidationErrors.ts
+++ b/ts/packages/core/src/errors/ValidationErrors.ts
@@ -78,6 +78,7 @@ export class JsonSchemaToZodError extends ComposioError {
...options,
code: options.code || ValidationErrorCodes.JSON_SCHEMA_TO_ZOD_ERROR,
});
+ this.name = 'JsonSchemaToZodError';
}
}
@@ -95,5 +96,6 @@ export class JsonSchemaRefResolutionError extends ComposioError {
...options,
code: options.code || ValidationErrorCodes.JSON_SCHEMA_REF_RESOLUTION_ERROR,
});
+ this.name = 'JsonSchemaRefResolutionError';
}
}
diff --git a/ts/packages/core/test/errors/errorNames.test.ts b/ts/packages/core/test/errors/errorNames.test.ts
new file mode 100644
index 000000000..6b1d87a0b
--- /dev/null
+++ b/ts/packages/core/test/errors/errorNames.test.ts
@@ -0,0 +1,32 @@
+import { describe, it, expect } from 'vitest';
+import { ComposioError } from '../../src/errors/ComposioError';
+import { ComposioToolVersionRequiredError } from '../../src/errors/ToolErrors';
+import {
+ JsonSchemaToZodError,
+ JsonSchemaRefResolutionError,
+} from '../../src/errors/ValidationErrors';
+
+// The base ComposioError assigns `name` as a class field, so a subclass that does
+// not reassign `this.name` in its constructor inherits the base value and reports
+// 'ComposioError'. error.name is forwarded to error telemetry (see Telemetry.ts),
+// where that silently mis-groups distinct error types under the base name. These
+// three subclasses had omitted the reassignment their ~30 siblings all perform.
+describe('ComposioError subclass names', () => {
+ it('ComposioToolVersionRequiredError reports its own name', () => {
+ const error = new ComposioToolVersionRequiredError();
+ expect(error).toBeInstanceOf(ComposioError);
+ expect(error.name).toBe('ComposioToolVersionRequiredError');
+ });
+
+ it('JsonSchemaToZodError reports its own name', () => {
+ const error = new JsonSchemaToZodError();
+ expect(error).toBeInstanceOf(ComposioError);
+ expect(error.name).toBe('JsonSchemaToZodError');
+ });
+
+ it('JsonSchemaRefResolutionError reports its own name', () => {
+ const error = new JsonSchemaRefResolutionError();
+ expect(error).toBeInstanceOf(ComposioError);
+ expect(error.name).toBe('JsonSchemaRefResolutionError');
+ });
+});