Repository navigation
Description
What's wrong
A build is never removed when its workflow or pipeline definition is deleted, as long as the API keeps answering for it.
GitHub. GitHub.UpdateBuildsAsync adds or renames a Build for every entry in GitHubWorkflows.List(...), but it never removes one and never reads workflow.State. GitHub's "list repository workflows" endpoint keeps returning a workflow whose file was deleted (with state: "deleted") for as long as the workflow has runs. ListByWorkflow for that id still returns 200 with the old runs. So the only removal path, catch (NotFoundException) in UpdateBuildAsync, never fires.
Azure DevOps. AzureDevOps.cs has no removal path at all; it contains no TryRemove. UpdateBuildsAsync only adds definitions from GetDefinitionsAsync, and UpdateBuildAsync has no not-found handling. A deleted definition either keeps its last status, or its exception lands in the generic VssServiceException catch and sets ProviderStatus.Error on every poll.
Failure scenario
- A repo has
ci.ymlandold-release.yml, and the lastold-release.ymlrun failed. - The user deletes
old-release.yml. - BuildMonitor shows an "old-release" row with a red Failure status for the rest of the session, and after restarts too, because builds are persisted in AppData.
BuildSynckeeps polling the workflow every 60–120 s, spending rate-limit budget on a pipeline that no longer exists.
The Azure DevOps case: after a pipeline is deleted, its row stays forever, and if the API throws for it, the provider status flips to Error on every poll.
PruneOrphanedAndCompletedSyncs would already clean up the sync once the Build leaves repository.Builds, because BuildSync.IsOrphaned becomes true. This is separate from #312, which covers archived or removed repositories.
Suggested fix
- GitHub:
- In
UpdateBuildsAsync, treat workflows whoseState == WorkflowState.Deletedas absent. - After a successful and complete listing, remove every
repository.Buildsentry whose id is not among the live workflows, then callQueueSaveAppData(). Workflows.List(owner, repo)returns only the first page (30 by default). Fetch all pages before pruning, or repos with more than 30 workflows would lose real builds.
- In
- Azure DevOps:
- In
UpdateBuildsAsync, remove builds whose definition id is no longer returned byGetDefinitionsAsync. - In
UpdateBuildAsync, catchDefinitionNotFoundExceptionand remove the build, matching GitHub'sNotFoundExceptionhandling.
- In
- Prune only after the listing request succeeded, so a transient failure never empties a repository.
Acceptance criteria
- When a listing drops a definition, the repository loses that
Build, and itsBuildSyncis pruned on the next pass. - A GitHub workflow with state
deletedis not shown. - A failed listing removes nothing.
- A repository with more than 30 workflows keeps all of its live builds.
Activity
matt-edmondson commentedon Oct 6, 2026
Triage
BuildMonitor/Providers/GitHub.cs(UpdateBuildsAsync, which needs workflow-state filtering and full pagination) andAzureDevOps.cs(no removal path at all).Generated by Claude Code