Skip to content

Fix fatal crash on duplicate prompt context metrics - #751

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/duplicate-metrics-crash
Open

Fix fatal crash on duplicate prompt context metrics#751
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/duplicate-metrics-crash

Conversation

@sentry

@sentry sentry Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a fatal crash (EXC_BREAKPOINT: Duplicate values for key) occurring when PromptContextEntryMetricsSnapshot.init attempts to construct dictionaries (metricsByFileID and metricsByStandardizedFullPath) using Dictionary(uniqueKeysWithValues:).

The root cause is that the metrics array passed to the initializer can contain PromptContextEntryMetric items with identical fileIDs or standardizedFullPaths, especially when the same file is included multiple times in the prompt context. uniqueKeysWithValues does not handle duplicate keys and crashes.

The fix replaces Dictionary(uniqueKeysWithValues:) with Dictionary(_:uniquingKeysWith: { first, _ in first }) for both dictionary constructions. This ensures that if duplicate keys are encountered, the first value for that key is retained, preventing the crash and allowing the system to gracefully handle such scenarios.

Fixes REPOPROMPT-GJ

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.

0 participants