Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ await esbuild.build({
platform: 'node',
format: 'esm',
minify: true,
keepNames: true,
jsx: 'automatic',
// Inject require shim for ESM compatibility with CommonJS dependencies
banner: {
Expand Down
17 changes: 17 additions & 0 deletions integ-tests/add-remove-resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,23 @@ describe('integration: add and remove resources', () => {
});
});

describe('add validation failure telemetry', () => {
it('emits ValidationError for add memory with missing --name', async () => {
telemetry.clearEntries();
const result = await runCLI(['add', 'memory', '--strategies', 'SEMANTIC', '--json'], project.projectPath, {
env: telemetry.env,
});

expect(result.exitCode).toBe(1);
telemetry.assertMetricEmitted({
command: 'add.memory',
exit_reason: 'failure',
error_name: 'ValidationError',
error_source: 'user',
});
});
});

describe('remove all', () => {
it('resets all schemas and emits telemetry', async () => {
const result = await runCLI(['remove', 'all', '--yes', '--json'], project.projectPath, {
Expand Down
2 changes: 2 additions & 0 deletions integ-tests/create-edge-cases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ describe.skipIf(!prereqs.npm || !prereqs.git)('integration: create edge cases',
telemetry.assertMetricEmitted({
command: 'create',
exit_reason: 'failure',
error_name: 'ValidationError',
error_source: 'user',
agent_language: 'python',
has_agent: 'true',
});
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/create/command.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getWorkingDirectory, serializeResult } from '../../../lib';
import { ValidationError, getWorkingDirectory, serializeResult } from '../../../lib';
import type {
BuildType,
ModelProvider,
Expand Down Expand Up @@ -132,7 +132,7 @@ async function handleCreateCLI(options: CreateOptions): Promise<void> {
async () => {
const validation = validateCreateOptions(options, cwd);
if (!validation.valid) {
throw new Error(validation.error);
throw new ValidationError(validation.error!);
Comment thread
Hweinstock marked this conversation as resolved.
}
const green = '\x1b[32m';
const reset = '\x1b[0m';
Expand Down
3 changes: 2 additions & 1 deletion src/cli/primitives/AgentPrimitive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ConflictError,
NoProjectError,
ResourceNotFoundError,
ValidationError,
findConfigRoot,
serializeResult,
setEnvVar,
Expand Down Expand Up @@ -301,7 +302,7 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
await runCliCommand('add.agent', !!cliOptions.json, async () => {
const validation = validateAddAgentOptions(cliOptions);
if (!validation.valid) {
throw new Error(validation.error);
throw new ValidationError(validation.error!);
}

// Parse custom claims JSON if provided (already validated by validateAddAgentOptions)
Expand Down
3 changes: 2 additions & 1 deletion src/cli/primitives/CredentialPrimitive.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ConflictError,
ResourceNotFoundError,
ValidationError,
findConfigRoot,
getEnvVar,
serializeResult,
Expand Down Expand Up @@ -315,7 +316,7 @@ export class CredentialPrimitive extends BasePrimitive<AddCredentialOptions, Rem
});

if (!validation.valid) {
throw new Error(validation.error);
throw new ValidationError(validation.error!);
}

const addOptions =
Expand Down
4 changes: 2 additions & 2 deletions src/cli/primitives/GatewayPrimitive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResourceNotFoundError, findConfigRoot, serializeResult, toError } from '../../lib';
import { ResourceNotFoundError, ValidationError, findConfigRoot, serializeResult, toError } from '../../lib';
import type { Result } from '../../lib/result';
import type {
AgentCoreGateway,
Expand Down Expand Up @@ -191,7 +191,7 @@ export class GatewayPrimitive extends BasePrimitive<AddGatewayOptions, Removable
await runCliCommand('add.gateway', !!cliOptions.json, async () => {
const validation = validateAddGatewayOptions(cliOptions);
if (!validation.valid) {
throw new Error(validation.error);
throw new ValidationError(validation.error!);
}

// Parse custom claims JSON if provided (already validated)
Expand Down
3 changes: 2 additions & 1 deletion src/cli/primitives/GatewayTargetPrimitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
APP_DIR,
MCP_APP_SUBDIR,
ResourceNotFoundError,
ValidationError,
findConfigRoot,
requireConfigRoot,
serializeResult,
Expand Down Expand Up @@ -323,7 +324,7 @@ export class GatewayTargetPrimitive extends BasePrimitive<AddGatewayTargetOption
await runCliCommand('add.gateway-target', !!cliOptions.json, async () => {
const validation = await validateAddGatewayTargetOptions(cliOptions);
if (!validation.valid) {
throw new Error(validation.error);
throw new ValidationError(validation.error!);
Comment thread
Hweinstock marked this conversation as resolved.
}

// Map CLI flag values to internal types
Expand Down
4 changes: 2 additions & 2 deletions src/cli/primitives/MemoryPrimitive.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResourceNotFoundError, findConfigRoot, serializeResult, toError } from '../../lib';
import { ResourceNotFoundError, ValidationError, findConfigRoot, serializeResult, toError } from '../../lib';
import type { Result } from '../../lib/result';
import type {
Memory,
Expand Down Expand Up @@ -204,7 +204,7 @@ export class MemoryPrimitive extends BasePrimitive<AddMemoryOptions, RemovableMe
});

if (!validation.valid) {
throw new Error(validation.error);
throw new ValidationError(validation.error!);
}

const result = await this.add({
Expand Down
Loading