sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Tests: Spammy fatal logs from SentryFileManager

Open philipphofmann opened this issue 9 months ago • 0 comments

Description

When checking the test logs in CI we can see that the SentryFileManager spams the logs with fatal messages like the following ones

[Sentry] [fatal] [timeIntervalSince1970:1748454849.6005049] [SentryFileManager:63] Failed to create directory, path is too long: (null)
[Sentry] [fatal] [timeIntervalSince1970:1748454849.6005502] [SentryFileManager:140] Failed to create Sentry SDK working directory: (null)
[Sentry] [fatal] [timeIntervalSince1970:1748454849.6008] [SentryFileManager:63] Failed to create directory, path is too long: (null)
[Sentry] [fatal] [timeIntervalSince1970:1748454849.600837] [SentryFileManager:140] Failed to create Sentry SDK working directory: (null)
[Sentry] [fatal] [timeIntervalSince1970:1748454849.605884] [SentryFileManager:63] Failed to create directory, path is too long: (null)
[Sentry] [fatal] [timeIntervalSince1970:1748454849.605921] [SentryFileManager:140] Failed to create Sentry SDK working directory: (null)
[Sentry] [fatal] [timeIntervalSince1970:1748454849.606196] [SentryFileManager:63] Failed to create directory, path is too long: (null)
[Sentry] [fatal] [timeIntervalSince1970:1748454849.60624] [SentryFileManager:140] Failed to create Sentry SDK working directory: (null)

You can reproduce this by running the unit tests SentrySerializationTests on iOS. The clearTestState calls SentrySDK.close, which then calls AppStateManager, which tries to init a FileManager, but the options are nil.

Image

The SentryDependencyContainer.fileManger property is nonnullable, but it actually return nil when there are no options bound to the SDK.

A PR that could be related to fixing this problem is https://github.com/getsentry/sentry-cocoa/pull/5315, which will require passing in the options when retrieving a file manager.

An easy fix is that the SentryFileManager doesn't print a fatal error message when passing in nil for the options.

philipphofmann avatar May 28 '25 18:05 philipphofmann