Repository: borgbackup/borg

Issue:
borg2: borg transfer fails with zlib compressed archive in borg 1.x repo
## Have you checked borgbackup docs, FAQ, and open GitHub issues?
Yes

## Is this a BUG / ISSUE report or a QUESTION?
BUG

## System information. For client/server mode post info for both machines.

#### Your borg version (borg -V).
❯ borg -V
borg 2.0.0b7

#### Operating system (distribution) and version.
Arch Linux

#### Hardware / network configuration, and filesystems used.
It is an external USB disk with a btrfs GPT partition with default options. Btrfs scrub reports no error.

#### How much data is handled by borg?
Around 1.5TB.

#### Full borg commandline that lead to the problem (leave away excludes and passwords)
`❯ borg --repo /mnt/custom/borg2 transfer --other-repo /mnt/backups/borg --compress=zstd,10 --recompress=always --upgrader=From12To20`

## Describe the problem you're observing.
borg transfer from old repo to new is failing with an AssertError.  The new repo was created using
`borg --repo /mnt/custom/borg2 rcreate --other-repo=/mnt/backups/borg -e repokey-aes-ocb`

#### Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.
Yes, everytime I run the transfer command without --dry-run
Since the exception contains messages about cache, I tried rm -rf ~/.cache/borg and it doesn't help.

#### Include any warning/errors/backtraces from the system logs
```
downloads-2018-01-05 01:43:44.712277: archive is already present in destination repo, skipping.
home-2018-01-05 11:20:02.644243: copying archive to destination repo...
Local Exception

Error:

AssertionError: 

If reporting bugs, please include the following:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/borg/archiver/__init__.py", line 630, in main
    exit_code = archiver.run(args)
                ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg/archiver/__init__.py", line 536, in run
    return set_ec(func(args))
                  ^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg/archiver/_common.py", line 223, in wrapper
    return method(self, args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg/archiver/_common.py", line 156, in wrapper
    return method(self, args, repository=repository, cache=cache_, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg/archiver/transfer_cmd.py", line 131, in do_transfer
    chunk_entry = cache.add_chunk(
                  ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg/cache.py", line 954, in add_chunk
    cdata = self.repo_objs.format(id, meta, data, compress=compress, size=size, ctype=ctype, clevel=clevel)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/borg/repoobj.py", line 40, in format
    assert isinstance(meta, dict)
AssertionError

Platform: Linux p4 6.5.1.arch1.r1204752.b56e84bccab0 #1 SMP PREEMPT_DYNAMIC Mon, 25 Sep 2023 01:09:30 +0000 x86_64
Linux: Unknown Linux  
Borg: 2.0.0b7  Python: CPython 3.11.5 msgpack: 1.0.5 fuse: llfuse 1.5.0 [pyfuse3,llfuse]
PID: 3900158  CWD: /mnt/backups
sys.argv: ['/usr/bin/borg', '--repo', '/mnt/custom/borg2', 'transfer', '--other-repo', '/mnt/backups/borg', '--compress=zstd,10', '--recompress=always', '--upgrader=From12To20']
SSH_ORIGINAL_COMMAND: None
```


Discussion:

Resolving patch:
diff --git a/src/borg/testsuite/compress.py b/src/borg/testsuite/compress.py
--- a/src/borg/testsuite/compress.py
+++ b/src/borg/testsuite/compress.py
@@ -50,7 +50,7 @@ def test_lz4_buffer_allocation(monkeypatch):
 @pytest.mark.parametrize("invalid_cdata", [b"\xff\xfftotalcrap", b"\x08\x00notreallyzlib"])
 def test_autodetect_invalid(invalid_cdata):
     with pytest.raises(ValueError):
-        Compressor(**params, legacy_mode=True).decompress({}, invalid_cdata)
+        Compressor(**params, legacy_mode=True).decompress(None, invalid_cdata)
 
 
 def test_zlib_legacy_compat():
@@ -61,7 +61,7 @@ def test_zlib_legacy_compat():
         meta1, cdata1 = c.compress({}, DATA)
         cdata2 = zlib.compress(DATA, level)
         assert cdata1 == cdata2
-        meta2, data2 = c.decompress({}, cdata2)
+        meta2, data2 = c.decompress(None, cdata2)
         assert DATA == data2
 
 


Test patch: