Skip to content

Commit 19fa0fc

Browse files
cameroncookeclaude
andcommitted
fix(sentry): Resolve PR review findings
Redact Sentry tag values in beforeSend, remove the duplicate axe.path_mode tag, and delete the Sentry audit report with local filesystem paths. Also extract getErrorKind into a shared utility to remove duplicate implementations in config-store and tool-invoker. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a9f0726 commit 19fa0fc

6 files changed

Lines changed: 21 additions & 199 deletions

File tree

docs/SENTRY_AUDIT_REPORT_2026-02-11.md

Lines changed: 0 additions & 184 deletions
This file was deleted.

src/runtime/tool-invoker.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ToolCatalog, ToolDefinition, ToolInvoker, InvokeOptions } from './types.ts';
22
import type { ToolResponse } from '../types/common.ts';
33
import { createErrorResponse } from '../utils/responses/index.ts';
4+
import { getErrorKind } from '../utils/errors.ts';
45
import { DaemonClient } from '../cli/daemon-client.ts';
56
import { ensureDaemonRunning, DEFAULT_DAEMON_STARTUP_TIMEOUT_MS } from '../cli/daemon-control.ts';
67
import { log } from '../utils/logger.ts';
@@ -48,13 +49,6 @@ function buildDaemonEnvOverrides(opts: InvokeOptions): Record<string, string> |
4849
return Object.keys(envOverrides).length > 0 ? envOverrides : undefined;
4950
}
5051

51-
function getErrorKind(error: unknown): string {
52-
if (error instanceof Error) {
53-
return error.name || 'Error';
54-
}
55-
return typeof error;
56-
}
57-
5852
function mapRuntimeToSentryToolRuntime(runtime: InvokeOptions['runtime']): SentryToolRuntime {
5953
switch (runtime) {
6054
case 'daemon':

src/utils/__tests__/sentry-redaction.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ describe('sentry redaction', () => {
3333
output: 'log at /Users/cam/project/build.log',
3434
attempts: 1,
3535
},
36+
tags: {
37+
xcodePath: '/Users/cam/Applications/Xcode.app',
38+
},
3639
};
3740

3841
const redacted = __redactEventForTests(event);
@@ -50,6 +53,7 @@ describe('sentry redaction', () => {
5053
);
5154
expect(redacted.extra?.output).toBe('log at /Users/<redacted>/project/build.log');
5255
expect(redacted.extra?.attempts).toBe(1);
56+
expect(redacted.tags?.xcodePath).toBe('/Users/<redacted>/Applications/Xcode.app');
5357
});
5458

5559
it('parses xcode version metadata safely', () => {

src/utils/config-store.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from './project-config.ts';
99
import type { DebuggerBackendKind } from './debugger/types.ts';
1010
import type { UiDebuggerGuardMode } from './runtime-config-types.ts';
11+
import { getErrorKind } from './errors.ts';
1112

1213
export type RuntimeConfigOverrides = Partial<{
1314
enabledWorkflows: string[];
@@ -134,13 +135,6 @@ function parseDebuggerBackend(value: string | undefined): DebuggerBackendKind |
134135
return undefined;
135136
}
136137

137-
function getErrorKind(error: unknown): string {
138-
if (error instanceof Error) {
139-
return error.name || 'Error';
140-
}
141-
return typeof error;
142-
}
143-
144138
function setIfDefined<K extends keyof RuntimeConfigOverrides>(
145139
config: RuntimeConfigOverrides,
146140
key: K,

src/utils/errors.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ export class AxeError extends XcodeBuildMCPError {
107107
}
108108
}
109109

110+
export function getErrorKind(error: unknown): string {
111+
if (error instanceof Error) {
112+
return error.name || 'Error';
113+
}
114+
return typeof error;
115+
}
116+
110117
// Helper to create a standard error response
111118
export function createErrorResponse(message: string, details?: string): ToolResponse {
112119
const detailText = details ? `\nDetails: ${details}` : '';

src/utils/sentry.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ function redactEvent(event: Sentry.ErrorEvent): Sentry.ErrorEvent {
104104
}
105105
}
106106

107+
if (event.tags) {
108+
for (const [key, value] of Object.entries(event.tags)) {
109+
if (typeof value === 'string') {
110+
event.tags[key] = redactPathLikeData(value);
111+
}
112+
}
113+
}
114+
107115
return event;
108116
}
109117

@@ -223,7 +231,6 @@ export function setSentryRuntimeContext(context: SentryRuntimeContext): void {
223231
setTagIfDefined('config.xcode_ide_workflow_enabled', boolToTag(context.xcodeIdeWorkflowEnabled));
224232
setTagIfDefined('axe.available', boolToTag(context.axeAvailable));
225233
setTagIfDefined('axe.source', context.axeSource);
226-
setTagIfDefined('axe.path_mode', context.axeSource);
227234
setTagIfDefined('axe.version', context.axeVersion);
228235
setTagIfDefined('xcode.developer_dir', context.xcodeDeveloperDir);
229236
setTagIfDefined('xcode.xcodebuild_path', context.xcodebuildPath);

0 commit comments

Comments
 (0)