Skip to content

fix: upgrade BSA to 0.2.5 to fix frozen app anonymisation crashes (#246) - #250

Merged
boscorat merged 9 commits into
masterfrom
246-bug-anonymisation-error
Oct 7, 2026
Merged

boscorat merged 9 commits into
masterfrom
246-bug-anonymisation-error

Conversation

@boscorat

@boscorat boscorat commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Fix for Issue #246: Anonymisation Fails on Frozen macOS App

Problem

Anonymisation crashes on the macOS frozen app bundle (.app) with:

FileNotFoundError: /Applications/openstan.app/Contents/MacOS/lib/library.zip/bank_statement_anonymiser/always_anonymise_system.toml

This also affects Windows and Linux frozen app bundles (cx_Freeze/PyInstaller).

Root Cause

BSA v0.2.4 used importlib.resources.as_file() context manager to extract bundled config files. The temporary extracted files were deleted when the context exited, leaving a path to a non-existent file. In frozen apps, this caused immediate crashes because resources are bundled in zip archives and extraction temp files are deleted before anonymise_pdf() can use them.

Solution

Upgraded to BSA v0.2.5 which includes the fix:

  • System configs are now loaded at module import time into cached dicts
  • Removed the per-call resource extraction that was failing in frozen apps
  • API remains backward compatible: bsa.anonymise_pdf() still accepts path parameters
  • Benefits:
    • ✅ Fixes frozen app crashes on all platforms (macOS, Windows, Linux)
    • ✅ Better performance (configs loaded once at startup)
    • ✅ Cleaner implementation (no context manager lifetime issues)

Testing

Openstan Tests: 177/177 PASSED ✅

  • Full unit test suite
  • Specifically validated: 15 anonymise_presenter tests
  • Config loading, retain_descriptions, batch processing all tested

BSA Integration Verified ✅

  • BSA v0.2.5 installed and working
  • System configs loaded at import time
  • API compatibility confirmed
  • BSA's own 643 tests all pass with frozen app fix

Changes in This PR

  • pyproject.toml: Bumped uk-bank-statement-anonymiser from 0.2.4 → 0.2.5
  • uv.lock: Updated dependency lock file
  • documentation screenshots updated to reflect logging and anonymisation changes

Related PRs


Pre-merge Checklist

  • All 177 unit tests pass
  • BSA integration tests pass
  • No API breakage
  • Commit message follows Conventional Commits format
  • Ready for review

Jason Farrar added 2 commits October 6, 2026 15:50
Add bank_statement_anonymiser config files (always_anonymise_system.toml,
never_anonymise_system.toml) to the explicit include_files list in cx_Freeze.

While the BSA v0.2.5+ fix loads configs at import time (avoiding resource
extraction issues in frozen apps), this ensures the files are also extracted
to disk as a safety net for edge cases.

Related to issue #246 - Anonymisation error on macOS frozen app.
Updates BSA dependency to v0.2.5 which includes critical fix for issue #246:
frozen app anonymisation crashes on macOS/Windows/Linux.

Changes in BSA 0.2.5:
- System configs (always_anonymise_system.toml, never_anonymise_system.toml)
  are now loaded at module import time into cached dicts, fixing frozen app
  resource loading failures caused by importlib.resources.as_file() context
  manager cleanup.
- API remains backward compatible: bsa.anonymise_pdf() still accepts
  always_anonymise_path and never_anonymise_path parameters.
- All 643 BSA unit tests pass with new config loading behavior.

Testing:
- ✅ 177 openstan unit tests pass
- ✅ 15 anonymise_presenter tests pass (BSA integration layer)
- ✅ BSA 0.2.5 library verified: configs loaded at import time
- ✅ API compatibility confirmed

Fixes: #246
@boscorat boscorat linked an issue Oct 7, 2026 that may be closed by this pull request
@boscorat
boscorat requested a balanced review from Copilot October 7, 2026 09:47

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The lock file pulls in an out-of-scope polars major version upgrade (1.x → 2.0) affecting directly-imported code that needs verification, and the comment insertion in cx_freeze_setup.py left an orphaned sentence fragment.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR upgrades the uk-bank-statement-anonymiser (BSA) dependency from 0.2.4 to 0.2.5 to resolve issue #246, where anonymisation crashed in frozen app bundles (.app/cx_Freeze) because BSA 0.2.4 extracted bundled TOML configs via a short-lived importlib.resources.as_file() context manager that deleted the temp file before use. BSA 0.2.5 loads system configs at import time instead. The PR also hardens cx_freeze_setup.py by explicitly bundling BSA's system TOML config files as a defensive safety net.

Changes:

  • Bump uk-bank-statement-anonymiser to 0.2.5 in pyproject.toml and uv.lock.
  • Add an explicit include_files block in cx_freeze_setup.py to bundle always_anonymise_system.toml / never_anonymise_system.toml, failing loudly if absent.
  • Incidental lock-file upgrades to several transitive/dev dependencies, including a polars 1.44.2 → 2.0.0 major version jump.
File Description
pyproject.toml Bumps the anonymiser pin to ==0.2.5; clean and consistent with the PR goal.
uv.lock Updates the anonymiser plus several unrelated packages, notably a polars major version bump (1.x → 2.0) that exceeds the stated scope.
cx_freeze_setup.py Adds explicit bundling of BSA config files; insertion accidentally dropped the first line of the following icon-regeneration comment.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cx_freeze_setup.py
boscorat and others added 7 commits October 7, 2026 10:52
Add note about regenerating PNG on Linux CI.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jason Farrar <farrar.jason1@gmail.com>
- Update all description: fields to 150-160 chars for Google SERP snippets (30 pages)
- Fix zensical blog plugin configuration: post_dir: blog -> post_dir: posts
- Move multi-account-bank-export.md into docs/blog/posts/ to resolve build warnings
- Add opening paragraphs for AI-summarisability (video-tutorials.md, logging.md)
- Add logging cross-links to import/export/anonymise guides for content role clarity
- Add See Also / Related Topics sections for internal link hierarchy (5+ links each)
- Fix H1->H3 skip in index.md heading hierarchy
- zensical build now completes cleanly with zero warnings
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jason Farrar <farrar.jason1@gmail.com>
- Create comprehensive guides index page at docs/guides/index.md with links to all 11 guides
- Enable sitemap plugin with asset exclusion to prevent non-page URLs from being indexed
- Rename SCREENSHOTS.md → SCREENSHOTS.txt to prevent developer docs from appearing in sitemap
- Add comment in mkdocs.yml documenting blog post URL migration (post_dir: blog → posts)
- All 43 user-facing pages + 1 blog post now properly indexed in sitemap.xml
- Guides index resolves 404 error on /guides/ path; improves internal link hierarchy
Updated the description and fixed links in the guides index.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jason Farrar <farrar.jason1@gmail.com>
…tion

- Enable Zensical's built-in redirects plugin
- Map old blog post URL /blog/multi-account-bank-export/ to new /blog/posts/multi-account-bank-export/
- Generates proper redirect HTML with meta refresh and JavaScript fallback for GitHub Pages
- Ensures old links maintain SEO value (canonical link + redirect)
- Handles blog post URL path migration after post_dir config change (blog → posts)

Verification:
- zensical build completes cleanly with no warnings
- Redirect HTML generated at site/blog/multi-account-bank-export/index.html
- Canonical link points to new URL for proper SEO handling
- Works on GitHub Pages (meta refresh + JavaScript redirect)
@boscorat
boscorat force-pushed the 246-bug-anonymisation-error branch from 76713d3 to dd9852d Compare October 7, 2026 11:16
@boscorat
boscorat merged commit 99b833a into master Oct 7, 2026
2 checks passed
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.

bug: anonymisation error

2 participants