Skip to content

repository: clear error for borg 1.x repositories, fixes crash w/o --from-borg1 - #10418

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:legacy-repo-error
Sep 24, 2026
Merged

ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:legacy-repo-error

Conversation

@ThomasWaldmann

@ThomasWaldmann ThomasWaldmann commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Description

Opening a borg 1.x repository with borg 2 without --from-borg1 crashed with a "Local Exception" traceback. Examples are borg -r /path/to/v1repo repo-info, or borg transfer --other-repo v1repo without --from-borg1. A borg 1.x repository has a config file where borg 2 expects the config/ namespace, so loading the config/config store object failed differently per platform and backend:

  • local repository: NotADirectoryError: [Errno 20] Not a directory: '.../config/config'
  • ssh://: the remote borg serve --rest answered HTTP 500 -> requests.exceptions.HTTPError
  • on Windows, both came out as "not found" instead (ObjectNotFound / HTTP 404), which borg reported as InvalidRepository

borgstore 0.6.4 (borgbackup/borgstore#228) reports a name below an object as ObjectNotFound on all platforms. So this PR requires borgstore ~= 0.6.4, and a borg 1.x repository now always ends up in the StoreObjectNotFound branch of Repository._load_config. There, it looks at config via the store backend (Store.info only takes names below a namespace). If config is a file, it raises the new Repository.LegacyRepository error (rc 29):

... looks like a borg 1.x repository, use --from-borg1 to access it (e.g. with borg transfer).

Otherwise it continues as before (a store without a repository config). If the probe itself fails with a backend or OS error, it's treated as "not a borg 1.x repository".

A remote borg serve that still uses an older borgstore answers such a request with HTTP 500. In that case, the user still gets the traceback.

Same symptom as the closed #9010 and #8652 (which involved older borg 2 betas).

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate: test_open_legacy_repository[file|ssh] in repository_test.py; LegacyRepository added to the error list in docs/internals/frontends.rst; borgstore requirement bumped in pyproject.toml and docs/installation.rst
  • Tests pass (run tox or the relevant test subset): the test suite (except mount/FUSE) passes locally on macOS with borgstore 0.6.4
  • Commit messages are clean and reference related issues

🤖 Generated with Claude Code

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.38%. Comparing base (db0c4ac) to head (4164c09).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/repository.py 80.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10418   +/-   ##
=======================================
  Coverage   88.38%   88.38%           
=======================================
  Files         103      103           
  Lines       19029    19039   +10     
  Branches     2961     2962    +1     
=======================================
+ Hits        16819    16828    +9     
- Misses       1538     1540    +2     
+ Partials      672      671    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

…from-borg1

Opening a borg 1.x repository without --from-borg1 crashed with a traceback while
loading the config/config store object, because a borg 1.x repository has a config
*file* where borg 2 has the config/ namespace (NotADirectoryError for a local
repository, HTTP 500 via ssh://; InvalidRepository on Windows).

borgstore 0.6.4 reports a name below an object as ObjectNotFound on all platforms,
so require it. If config/config is not found, look at "config" via the store
backend and raise Repository.LegacyRepository (rc 29) if it is a file, telling the
user to use --from-borg1 (e.g. with borg transfer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ThomasWaldmann
ThomasWaldmann merged commit 8867ca8 into borgbackup:master Sep 24, 2026
27 of 28 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the legacy-repo-error branch September 24, 2026 19:14
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.

NotADirectoryError after 2.0.0b5 -> 2.0.0b19 migration

1 participant