Repository navigation
factory: setup's open issues tests pin issues alone and every failed count - #2168
Merged
Merged
Conversation
factory.repos available[] and the factory's /v1/repos rows gain
open_issues: open issues WITHOUT pull requests. open stays GitHub's
open_issues_count, which counts both. The count comes from one batched
GraphQL request per 100 listed repositories (aliases over
repository(owner,name){issues(states:OPEN){totalCount}}), so discovery
costs one request per REST page it already made. A batch GitHub refuses,
or a repository it does not answer, leaves open_issues absent: never 0
and never a guess.
Opt-in (CODEAF_LIVE_REPOS_OPEN_ISSUES=1, GH_TOKEN): the picker's own lister reads the real account's repositories, every request counted and anything but the REST list's GET or the GraphQL count refused.
The first-run setup's repository rows sent open_issues as GitHub's open_issues_count, issues and pull requests together, though the read the setup shows progress against counts issues alone. Discovery now asks the same batched GraphQL count the repository list uses (one request per page of 100, forge.OpenIssueCounts shared by both) and sends issues alone with open_issues_exact true. A repository GraphQL does not count keeps the combined number with open_issues_exact false: open_issues stays a required number, so no reader loses it. The read's own count is marked exact. The test guards that refuse GitHub writes treat a GraphQL query as the read it is; a mutation is still refused.
The guards that refuse GitHub writes took any POST /graphql whose query began with "query", so a second operation chosen by operationName, or a case-variant duplicate key read last by encoding/json, could carry a mutation past them. graphQLRead now passes a body only when its real keys, read token by token, are exactly "query" and optionally "variables" (no operationName, no duplicates, no other key), and a small lexer that skips strings, block strings and comments finds exactly one top-level operation opened by the keyword query and no mutation or subscription anywhere. The product's own open-issue count request, generated by its own code, passes.
…sts and every failed count A setup repository row with 18 open issues and 12 open pull requests (GitHub's open_issues_count 30) shows 18 with open_issues_exact when the batched GraphQL count answers, and keeps 30 without the flag when the request is refused, answers GraphQL errors with no data, leaves the repository's alias null, or answers something that is not JSON.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2154 has landed on app/v3; this PR is on app/v3.
What the user sees
#2154 already makes setup's repository rows count open issues apart from pull requests and say so with
open_issues_exact. The desktop app shows "18 issues" when the flag is true, and "30 open issues and PRs" when it is false. This PR adds tests only. It pins the exact case and each way the count can fail, so a later change cannot quietly bring back the combined number or invent a count.Wire shape (one setup repository row)
{"id":"acme/api","full_name":"acme/api","open_issues":18,"open_issues_exact":true, "...": "unchanged fields"}When GraphQL does not count the repository,
open_issuesis GitHub'sopen_issues_count(30) andopen_issues_exactisfalse.Tests
TestFactorySetupOpenIssuesExcludePullRequestsAndFallBackWhenTheCountFails(internal/factory/serve) drives the setup HTTP handler against a fake GitHub server. The repository list reportsopen_issues_count30 (18 issues + 12 PRs):r0.issues.totalCount18data: null+errorsr0null +errorsThe test passes on #2154's code. To check that it catches a regression, the line that applies the exact count was removed for one run. The test then failed with:
Gates
GATES_PLACEHOLDER
Limits
falserather than left out of the JSON, because factory: each repository says its open issues apart from pull requests #2154 does not tag the fieldomitempty. Readers that treat a missing flag as false see the same result.🤖 Generated with Claude Code