fix(issue): name missing issues and attachments in errors

tea issue close 999 printed "issue 999: not found (HTTP 404 GET …)" and
issue attachment view 1 9 blamed issue #1 for a missing attachment.
Batch commands (issue close, reopen, edit, milestone issue add and
remove) now report "issue 999: not found in alice/x", and attachment
commands "attachment 9 not found in alice/x#1".

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 00:17:08 +02:00
1 parent 56c6ffc80b
commit 01ced23a4a
5 files changed
+64 -15

No files matched your search

+25
View File
@@ -114,3 +114,28 @@ func TestIssueMutationsReportDoneLines(t *testing.T) {
run(true, "issue", "edit", "5", "--title", "Open one")
require.Equal(t, "✓ Edited issue alice/project#5 (Open one)\n", diagnostics.String())
}
func TestMissingItemsAreNamed(t *testing.T) {
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/api/v1/repos/alice/project" {
_, _ = w.Write([]byte(`{"full_name":"alice/project","has_issues":true,"has_pull_requests":true}`))
return
}
w.WriteHeader(http.StatusNotFound)
_, _ = w.Write([]byte(`{"message":"not found"}`))
}))
defer server.Close()
deps, _, _ := serverDeps(t, server.URL)
for _, test := range []struct {
args []string
want string
}{
{[]string{"issue", "close", "999"}, "issue 999: not found in alice/project"},
{[]string{"issue", "edit", "999", "--title", "x"}, "issue 999: not found in alice/project"},
{[]string{"issue", "attachment", "view", "1", "9"}, "attachment 9 not found in alice/project#1"},
{[]string{"issue", "attachment", "delete", "1", "9", "--yes"}, "attachment 9 not found in alice/project#1"},
} {
err := Execute(context.Background(), deps, append(test.args, "-R", "alice/project"))
require.EqualError(t, Explain(context.Background(), deps, err), test.want, test.args)
}
}