Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in addBreadcrumb: NSInvalidArgumentException: Invalid number value (infinite) in JSON write #3936

Open
ronyfadel opened this issue May 5, 2024 · 2 comments

Comments

@ronyfadel
Copy link

Platform

macOS

Environment

Production

Installed

Swift Package Manager

Version

7.31.5

Did it work on previous versions?

No response

Steps to Reproduce

If I try to add a breadcrumb with a number set to +inf (e.g. CMTime.positiveInfinity.seconds), Sentry crashes my app.

code to repro:

public extension SentrySDK {
  static func addBreadcrumb(_ message: String, level: SentryLevel = .info, category: String? = nil, data: [String: Any]? = nil) {
    let crumb = Breadcrumb()
    crumb.message = message
    crumb.level = level
    if let category {
      crumb.category = category
    }
    crumb.data = data
    self.addBreadcrumb(crumb: crumb)
  }
}

SentrySDK.addBreadcrumb("test", data: ["foo": CMTime.positiveInfinity])

crumb right before:

{

crumb: {
error: Invalid JSON data: Invalid character,
json_data: {"category":"default","data":{"language":"it","duration":inf,"translate_to":"fa"},"level":"info","message":"ac_subtitle_start","timestamp":"2024-05-05T01:07:36.116Z"}
},
language: it
}

Expected Result

App doesn't crash.

Actual Result

app crashes with.

Are you willing to submit a PR?

No response

@ronyfadel
Copy link
Author

cc @philipphofmann

@philipphofmann
Copy link
Member

@ronyfadel, this could be fixed with #3458 released in 8.17.1. Can you try to update to this version and see if the problem persists?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Status: Needs More Information
Development

No branches or pull requests

2 participants