Skip to content

Folder Encryption crashes on iPadOS — path.resolve is not a function #59

@Obsidiannite21

Description

@Obsidiannite21

From Claude:

Bug Description

Enabling Folder Encryption and opening a note inside the encrypted folder on iPadOS causes a save failure with the error:

Failed to save file "Secure Notes". path.resolve is not a function. (In 'path.resolve(filePath)', 'path.resolve' is undefined). Make a backup of the contents of this file now to avoid losing data.

The note content remains visible in the editor (still in memory) but the file cannot be saved. No data loss occurred because the write failed before modifying the file on disk, but the error is alarming and the feature is non-functional on mobile.

Environment

  • Device: iPad (iPadOS)
  • Obsidian version: Latest (mobile)
  • gpgCrypt version: 0.6.0
  • Encryption backend: OpenPGP.js

Steps to Reproduce

  1. Install gpgCrypt on iPadOS
  2. Configure with OpenPGP.js backend and generate/import a key pair
  3. Enable Folder Encryption in gpgCrypt settings
  4. Add a folder path (e.g., 🔒 Secure Notes)
  5. Open an existing note inside that folder
  6. Observe the error notification

Root Cause

The plugin uses Node.js path.resolve() in the folder encryption file-handling code. This function is not available in Obsidian's mobile JavaScript runtime (which runs in a WebView, not Node.js). The path module is a Node.js built-in that doesn't exist in browser/mobile environments.

Suggested Fix

Replace path.resolve(filePath) with Obsidian's vault-relative path APIs (e.g., normalizePath() from the Obsidian API, or simple string path manipulation), which work consistently across desktop and mobile.

Additional Context

  • Per-note encryption via context menu was not tested separately — the crash occurs during the folder encryption auto-trigger on note open/save.
  • The README notes "Support for mobile devices (only with OpenPGP.js)" but folder encryption appears to have been added later (v0.6.0) and may not have been tested on mobile.
  • After the error, the note appears empty in Obsidian even after force-closing and restarting the app, and even after disabling the plugin. The file content on disk is confirmed intact via MCP server — this appears to be an Obsidian cache issue caused by the failed save.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions