con / con/git-annex

annex.trashbin fails on local-remote drops with misleading "unknown remote" error

Open Beginner friendly
#274 0 comments 0 reactions 0 assignees View on GitHub
ai-uncurated bug
Dominant language
Python
Stars
29
Forks
5
PR merge metrics
No merged PRs in 30d

Description

`annex.trashbin` does not work when dropping content from a local git remote.
The drop fails with a misleading "unknown remote" diagnostic, even though the
configured trash remote IS defined in the remote repo's git config.

```
> git -C B annex drop --from A file.dat
drop file.dat (from A...)
annex.trashbin is set to the name of an unknown remote
failed
```

The drop never happens; nothing is moved to the trash; the file remains on A.

Introduced when `annex.trashbin` was added in `10.20251215` and still present
in `10.20260525` (current upstream — `Remote/Git.hs` untouched in the interim).

Root cause

`Remote/Git.hs:543` (in the `onLocalFast` path) reads the cached remotes list
directly:

```haskell
Annex.Content.removeAnnex (Annex.getState Annex.remotes) lock
```

In the sub-`Annex` for the local remote A, `Annex.remotes` has not been
populated — it's `[]`. `putouttrash'` then walks the empty list looking for
the trashbin remote by name, fails, and emits "unknown remote".

Every other caller of `removeAnnex` in the tree uses `Remote.List.remoteList`,
which lazily populates the cache. Suggested fix: change line 543 to use
`Remote.List.remoteList` instead.

Reproducer (POSIX shell, exits non-zero when bug fires)

```sh
#!/bin/sh
set -eux
PS4='> '

cd "$(mktemp -d "${TMPDIR:-/tmp}/gax-trashbin-XXXXXXX")"

git --version
git annex version | head -1

git init -q A && git -C A annex init -q a
git init -q B && git -C B annex init -q b
git init -q --bare trash

git -C A remote add trash "$PWD/trash"
git -C A config annex.trashbin trash

git -C B remote add A "$PWD/A"

dd if=/dev/zero of=A/file.dat bs=1024 count=4 2>/dev/null
git -C A annex add -q file.dat
git -C A -c user.email=x@x -c user.name=x commit -q -m p
git -C B fetch -q A
git -C B annex copy -q --from=A file.dat 2>/dev/null || git -C B annex get --from=A -q file.dat

# Bug: drop fails with "unknown remote".
git -C B annex drop --from=A -q file.dat
```

Version

```
Verified with: git-annex 10.20260421
Confirmed present in: 10.20260525 (Remote/Git.hs untouched in the interim)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Remote/Git.hs:543 and trace the onLocalFast path into Annex.Content.removeAnnex, then run the POSIX shell reproducer from the issue. Compare its remote lookup with the other removeAnnex callers using Remote.List.remoteList. Done means dropping from local remote A succeeds, the content is moved to the configured trash remote, and the misleading unknown-remote error is gone.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, haskell, shell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.