`gh run watch` drops annotations for jobs that are queued on the first poll
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
- #15221 par @aloneangel45 — fermée sans fusion
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 84/100
Piste de recherche
Lis renderRun dans pkg/cmd/run/watch/watch.go ainsi que les tests dans pkg/cmd/run/watch/watch_test.go. Reproduis le comportement de la première interrogation en attente et celui du cache, puis ajoute des tests pour les annotations ultérieures, plusieurs jobs terminés et les jobs terminés sans annotations. Le travail est terminé lorsque gh run watch conserve les annotations de chaque job et que les tests réussissent.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
gh run watch can show the wrong annotations, or none, for jobs in a run. Two cases:
- A job that is queued on the first poll never shows its annotations. Jobs that wait on
needs:start out asqueued. The watch loop caches every job whose status is notin_progress, includingqueued, so the job is cached with no annotations and is never fetched again. When it later fails, its error annotations are missing from the watch output and the final summary. - Annotations from one job overwrite another's. On a cache hit the loop does
annotations = as, which replaces everything collected so far in that poll instead of appending. The cache entry is also the running total for the poll, not that job's own annotations. Depending on job order, annotations from earlier jobs are dropped.
gh run view <id> shows the correct annotations for the same run, so the two commands disagree.
The code is in renderRun in pkg/cmd/run/watch/watch.go (trunk @ aec3808914, lines 247-271):
for _, job := range jobs {
if as, ok := annotationCache[job.ID]; ok {
annotations = as // replaces instead of appending
continue
}
as, err := shared.GetAnnotations(client, repo, job)
...
annotations = append(annotations, as...)
if job.Status != shared.InProgress { // also true for queued / waiting / pending
annotationCache[job.ID] = annotations // caches the running total, not this job's `as`
}
}
Affected version
Present in v2.95.0 and v2.106.0 (latest), and on trunk @ aec3808914. The logic is not platform-specific.
Steps to reproduce the behavior
Workflow (.github/workflows/repro.yml) in any test repo:
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: sleep 30
test:
needs: build
runs-on: ubuntu-latest
steps:
- run: |
echo "::error::TEST_JOB_ERROR"
exit 1
gh workflow run repro.yml- Right away,
gh run watch <run-id>(testis queued whilebuildruns) - When the run finishes, compare with
gh run view <run-id>
Expected vs actual behavior
Expected: the ANNOTATIONS section of gh run watch shows TEST_JOB_ERROR for the test job, the same as gh run view.
Actual: gh run watch shows no annotation for test, because the job was cached while it was queued. gh run view shows it.
Logs
I ran a direct port of the loop above over simulated polls. Current behavior vs. the proposed fix below:
case current fixed
test queued on poll 1, later errors [] [TEST_JOB_ERROR]
job order [slow, fast]; fast finishes first, [EARLY_FAST] [LATE_SLOW, EARLY_FAST]
slow emits a warning later
Proposed fix
Cache each job's own annotations only once the job has completed, and append cached entries instead of replacing:
for _, job := range jobs {
if as, ok := annotationCache[job.ID]; ok {
- annotations = as
+ annotations = append(annotations, as...)
continue
}
@@
annotations = append(annotations, as...)
- if job.Status != shared.InProgress {
- annotationCache[job.ID] = annotations
+ if job.Status == shared.Completed {
+ annotationCache[job.ID] = as
}
}
Suggested tests for pkg/cmd/run/watch/watch_test.go: a job that is queued on the first poll and later gets annotations; two completed jobs with different annotations, in either order; a completed job with zero annotations, which should still be cached and not re-fetched. Happy to open a PR with this if it helps.
- Langage dominant
- Go
- Étoiles
- 47.4k
- Forks
- 9.5k
- Merge moyen
- 18 h 34 min
- PR mergées (30 j)
- 70
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de cli/cli
-
`gh search prs --locked=false` silently ignores the requested search filterPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouvertebug gh-search priority-3
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
cli/cli#15188 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
gh skill update reports success when a repository cannot be resolvedPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouvertebug gh-skill priority-3
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
cli/cli#15092 · 4 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
`gh label list --json` prints nothing instead of `[]` when the repository has no labelsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverteblocked bug gh-label needs-investigation priority-3
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
cli/cli#15066 · 4 commentaires · 2 réactions ·
Les mainteneurs répondent en général sous 1 jour
-
`gh search code '"term"'` sends the typed quotes escaped (`q="\"term\""`) and finds nothingPeut-être à nouveau libre @Daiyuanranfeng l’a pris il y a 17 jours, et aucune pull request n’est ouverte. Ouverteauto-bugfix-fixing bug gh-search priority-3
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
cli/cli#15060 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
`gh run cancel` reports "Cannot cancel a workflow run that is completed" for any HTTP 409, hiding the real API errorPeut-être à nouveau libre @muadzhdz l’a pris il y a 19 jours, et aucune pull request n’est ouverte. Ouvertebug gh-run priority-3
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
cli/cli#15053 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
seriousm4x/UpSnap#1786 ·
-
bug feedback ui/ux
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
peasant-labs/peasant#1307 ·
Les mainteneurs répondent en général sous 1 jour
-
Reformat test names for single-protocol tests to start with Protocol/, i.e. gRPC/ or Websocket/Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
connectrpc/conformance#1211 ·
Les mainteneurs répondent en général sous 1 jour
-
bug effort:s impact:med raised-by:desk risk:low
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
medici-finance/assay#8342 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
hardening
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
inference-sim/inference-sim#2821 ·
Les mainteneurs répondent en général sous 1 jour