Skip to content

fix(apple): Match failedRequestTargets as regexes on Apple - #593

Open
jadlr wants to merge 2 commits into
getsentry:mainfrom
jadlr:fix/apple-failed-request-targets
Open

jadlr wants to merge 2 commits into
getsentry:mainfrom
jadlr:fix/apple-failed-request-targets

Conversation

@jadlr

@jadlr jadlr commented Oct 15, 2026

Copy link
Copy Markdown

📜 Description

Passes each failedRequestTargets entry to Cocoa both as a string and as an NSRegularExpression. A target matches when the URL contains it or when its regex matches anywhere in the URL. A target that isn't a valid regex is passed as a string only. The KDoc of failedRequestTargets now states the matching rule.

💡 Motivation and Context

Closes #591

Cocoa matches an NSString target as a substring and only an NSRegularExpression as a regex. KMP passed its targets as strings, so the default .* matched no URL, and HTTP client errors were never captured on Apple with default options.

As discussed in #591, the regex is not anchored, matching the JavaScript, Python, Cocoa and Dart SDKs.

After this fix, apps on default options will start sending HTTP client error events (500–599) from Apple. The changelog entry says so.

💚 How did you test it?

  • FailedRequestTargetsOptionsTest checks the targets KMP hands to Cocoa against a copy of Cocoa's matching rule, which isn't exposed to Kotlin. It covers the default target, a plain host, a regex, a regex matching part of a URL, and an invalid regex. On main, the default-target and both regex cases fail; with the fix, all pass.
  • iosSimulatorArm64Test and macosArm64Test: all tests pass.
  • spotlessApply, detekt and apiCheck pass.

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.

🤖 Generated with Claude Code

Cocoa matches a plain string in `failedRequestTargets` as a substring of
the URL and treats only NSRegularExpression targets as regexes. KMP
passed its targets through as strings, so the default `.*` matched no
URL and HTTP client errors were never captured on Apple.

Pass each target both as a string and as a regex, so a target matches
when the URL contains it or when its regex matches anywhere in the URL.
This matches the JavaScript, Python, Cocoa and Dart SDKs. Targets that
aren't valid regexes keep matching as strings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jadlr
jadlr force-pushed the fix/apple-failed-request-targets branch from 784c48d to 4cc2392 Compare October 16, 2026 06:24

@buenaflor buenaflor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

This branch has not been deployed

No deployments
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.

Default failedRequestTargets match no URL on Apple

2 participants