Skip to content

factory: setup's open issues tests pin issues alone and every failed count - #2168

Merged
santoshkumarradha merged 12 commits into
app/v3from
c37/g-setup-issue-count
Nov 3, 2026
Merged

santoshkumarradha merged 12 commits into
app/v3from
c37/g-setup-issue-count

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

#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_issues is GitHub's open_issues_count (30) and open_issues_exact is false.

Tests

TestFactorySetupOpenIssuesExcludePullRequestsAndFallBackWhenTheCountFails (internal/factory/serve) drives the setup HTTP handler against a fake GitHub server. The repository list reports open_issues_count 30 (18 issues + 12 PRs):

GraphQL answer open_issues open_issues_exact
r0.issues.totalCount 18 18 true
HTTP 502 30 false
data: null + errors 30 false
alias r0 null + errors 30 false
not JSON 30 false

The 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:

setup_open_issues_test.go:53: open_issues 30 exact false, want 18 and true

Gates

GATES_PLACEHOLDER

Limits

🤖 Generated with Claude Code

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.
Base automatically changed from c32/engine-open-issues to app/v3 November 2, 2026 12:28
@santoshkumarradha
santoshkumarradha marked this pull request as ready for review November 3, 2026 00:18
@santoshkumarradha
santoshkumarradha merged commit 8454fb4 into app/v3 Nov 3, 2026
@santoshkumarradha
santoshkumarradha deleted the c37/g-setup-issue-count branch November 3, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant