Skip to content

Conversation

@trojanfoe
Copy link
Contributor

@trojanfoe trojanfoe commented Dec 4, 2025

Ticket

JIRA-VPN-4586

Description

On the mobile platform, if the VPN log files fails to open we capture the error for reporting to the user.

Checklist:

  • Changelog

Screenshots (optional, if UI related)


This change is Reviewable

@trojanfoe trojanfoe requested review from mrkiwi and pronebird December 4, 2025 14:28
@trojanfoe trojanfoe force-pushed the bug/vpn-4586-mobile-log-file branch 2 times, most recently from 241bace to 7f02a6a Compare December 5, 2025 11:24
Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

As we discussed in internal comms. Let's debate in offline before merging this

@trojanfoe trojanfoe changed the title VPN-4586: Make failing to open log files fatal. VPN-4586: Return an error when the Nym log file is not created Dec 5, 2025
Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 2 unresolved discussions (waiting on @mrkiwi and @trojanfoe)


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 51 at r2 (raw file):

        if let Some(parent) = path.parent()
            && !parent.exists()
            && let Err(e) = std::fs::create_dir_all(parent)

IIRC create_dir_all() never fails if created directory already exists. Please verify. There is no need to check for parent.exists() neither.


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 62 at r2 (raw file):

        // Attempt to open the log file for writing
        let file = match OpenOptions::new()

Rewrite with .map_err()?; perhaps? In most cases Ok(x) => x is indication that something isn't right. Presence or return too.

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 3 unresolved discussions (waiting on @mrkiwi and @trojanfoe)


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 98 at r2 (raw file):

        .try_init()
        .map_err(|err| VpnError::CreateLogFile {
            details: format!("Failed to initialize OsLogger: {err}"),

Please correct the message. We're not initializing OsLogger alone, but tracing log.

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 4 unresolved discussions (waiting on @mrkiwi and @trojanfoe)


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/lib.rs line 224 at r2 (raw file):

    #[cfg(target_os = "ios")]
    let result = ios::init_logs(log_level, path, sentry_monitoring);

Nit: It's possible to wrap this in { .. } and return explicitly without going via result

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi and @trojanfoe)


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/android.rs line 8 at r2 (raw file):

use crate::error::VpnError;

pub(crate) fn init_logs(level: String) -> Result<(), VpnError> {

This method is infallible. Remove the Result

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 6 unresolved discussions (waiting on @mrkiwi and @trojanfoe)


nym-vpn-android/core/src/main/java/net/nymtech/vpn/backend/NymBackend.kt line 134 at r2 (raw file):

			initLogger(storagePath, LOG_LEVEL, config.sentryMonitoringEnabled)
				?: Timber.e("Failed to initialize backed logger")

typo in backend?

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 7 unresolved discussions (waiting on @mrkiwi and @trojanfoe)


nym-vpn-apple/NymMixnetTunnel/PacketTunnelProvider.swift line 135 at r2 (raw file):

        let logPath = LogFileManager.logFileURL(logFileType: .library)?.path()

        Task {

Problem that this makes logging initialization asynchronous. This needs to be synchronous somehow.

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 16 files reviewed, 8 unresolved discussions (waiting on @mrkiwi and @trojanfoe)


nym-vpn-core/crates/nym-firewall/src/net.rs line 29 at r2 (raw file):

/// When "allow local network" is enabled the app will allow traffic to these networks.
#[cfg_attr(
    any(target_os = "windows", target_os = "android", target_os = "ios"),

We don't compile nor even reference nym-firewall on mobile, please undo the change.

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

@pronebird reviewed 3 of 10 files at r1, 13 of 13 files at r2, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @mrkiwi and @trojanfoe)

@trojanfoe trojanfoe force-pushed the bug/vpn-4586-mobile-log-file branch from da7cef2 to 39a13bd Compare December 10, 2025 09:54
Copy link
Contributor Author

@trojanfoe trojanfoe left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @mrkiwi and @pronebird)


nym-vpn-core/crates/nym-firewall/src/net.rs line 29 at r2 (raw file):

Previously, pronebird (Andrej Mihajlov) wrote…

We don't compile nor even reference nym-firewall on mobile, please undo the change.

I was getting a warning in VSCode configured for iOS, so it was seeing this code.


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/android.rs line 8 at r2 (raw file):

Previously, pronebird (Andrej Mihajlov) wrote…

This method is infallible. Remove the Result

I would prefer both the iOS and the Android code to have similar semantics, infallible or not.


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 51 at r2 (raw file):

Previously, pronebird (Andrej Mihajlov) wrote…

IIRC create_dir_all() never fails if created directory already exists. Please verify. There is no need to check for parent.exists() neither.

Done.


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 62 at r2 (raw file):

Previously, pronebird (Andrej Mihajlov) wrote…

Rewrite with .map_err()?; perhaps? In most cases Ok(x) => x is indication that something isn't right. Presence or return too.

Huh? Ok(x) is indication that something isn't right?

@github-actions github-actions bot requested review from neacsu and pronebird December 10, 2025 09:55
Copy link
Contributor Author

@trojanfoe trojanfoe left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi, @neacsu, and @pronebird)


nym-vpn-apple/NymMixnetTunnel/PacketTunnelProvider.swift line 135 at r2 (raw file):

Previously, pronebird (Andrej Mihajlov) wrote…

Problem that this makes logging initialization asynchronous. This needs to be synchronous somehow.

I'll wait for Matt.

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi, @neacsu, and @trojanfoe)


nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 62 at r2 (raw file):

Previously, trojanfoe (Andy Duplain) wrote…

Huh? Ok(x) is indication that something isn't right?

Sorry for confusion. What I mean is that the expression can be rewritten using .map or .map_err with early return ? to achieve the same. The indication is when either leg of match returns the value verbatim (i.e Ok(x) => x or Err(e) => e).

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi, @neacsu, and @trojanfoe)


nym-vpn-apple/NymMixnetTunnel/PacketTunnelProvider.swift line 135 at r2 (raw file):

Previously, trojanfoe (Andy Duplain) wrote…

I'll wait for Matt.

Le'ts tackle that separately.

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

Reviewable status: 11 of 16 files reviewed, 1 unresolved discussion (waiting on @mrkiwi, @neacsu, and @trojanfoe)


nym-vpn-android/core/src/main/java/net/nymtech/vpn/backend/NymBackend.kt line 134 at r4 (raw file):

			startNetworkMonitorJob()

			initLogger(storagePath, LOG_LEVEL, config.sentryMonitoringEnabled)

Since we return an error here, would it not make sense to print it?

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

@pronebird reviewed 1 of 1 files at r4.
Reviewable status: 12 of 16 files reviewed, 1 unresolved discussion (waiting on @mrkiwi, @neacsu, and @trojanfoe)

Copy link
Collaborator

@pronebird pronebird left a comment

Choose a reason for hiding this comment

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

:lgtm:

@pronebird reviewed 4 of 5 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @mrkiwi and @neacsu)

@trojanfoe trojanfoe merged commit 88caeae into develop Dec 10, 2025
17 of 18 checks passed
@trojanfoe trojanfoe deleted the bug/vpn-4586-mobile-log-file branch December 10, 2025 13:04
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.

4 participants