github / github/gh-stack

unstack shows a generic/incorrect error instead of the real API rejection reason

Ouverte
#372 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
bug topic: stack management
Langage dominant
Go
Étoiles
1.5k
Forks
70
Merge moyen
1 j 8 h
PR mergées (30 j)
7

Description

## Summary

`gh stack unstack ` fails on a stack containing merged PRs, but the plain (non-debug) error message names an unrelated cause. The actual server-side reason is only visible with `GH_DEBUG=api`.

## Repro

1. Create a stack with `gh stack link` (or `submit`), e.g. `main <- a <- b <- c <- d <- e`.
2. Merge `a` and `b` (via merge queue or a normal merge — doesn't matter which).
3. Run `gh stack unstack ` on that stack.

## Actual

```
⚠ Some pull requests are queued for merge or have auto-merge enabled and remain stacked on GitHub
The stack was left in place — local tracking is unchanged
```

I verified via `gh api graphql` that **none** of the stack's PRs had `autoMergeRequest` set or a `mergeQueueEntry` — so the stated reason doesn't match reality.

Running the identical command with `GH_DEBUG=api gh stack unstack ` shows the real HTTP exchange:

```
POST /repos/{owner}/{repo}/stacks/{id}/unstack
< HTTP/2.0 422 Unprocessable Entity
{
"message": "Pull requests #.. , #.. cannot be removed from this stack",
"documentation_url": "https://docs.github.com/rest/pulls/stacks#remove-pull-requests-from-a-pull-request-stack",
"status": "422"
}
```

Interestingly, in the `GH_DEBUG=api` run the CLI's own final stderr line correctly echoed this specific message (`✗ Unstacking not allowed: Pull requests #.., #.. cannot be removed from this stack`) — a materially different, and accurate, explanation compared to the generic message shown without debug logging.

## Expected

The non-debug error message should reflect the actual REST API rejection (a stack can't be unstacked once any of its PRs have merged), not a generic, unrelated "queued for merge / auto-merge enabled" message.

## Environment

`gh-stack` version 0.0.8, installed via `gh extension install github/gh-stack`.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par reproduire `gh stack unstack ` sur une stack contenant des pull requests fusionnées, en comparant la sortie normale avec `GH_DEBUG=api`. Suivez la gestion des erreurs de unstack et la réponse 422 de la REST API ; c’est terminé lorsque la sortie sans débogage indique la véritable raison du rejet au lieu du message sans rapport queued-for-merge.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
github, go
Domaine
api, cli
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
67/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.