PR tools advertise index, not the canonical number — finish the #38 flip #45

Closed
opened 2026-07-03 19:42:45 +00:00 by mathias · 1 comment
Owner

Context

#38 (v0.4.0) made repo the canonical repo-identifier and kept name as an alias. Its body also named number as canonical for the issue/PR index. Most issue tools already use number canonical (with index aliased via the shim) — but the PR tools do not.

Finding

pr_merge (and other PR tools) advertise and read index as their canonical id field:

// internal/tools/pr_merge.go
"index":{"type":"integer","minimum":1},
...
"required":["owner","repo","index"]
...
Index int `json:"index"`

So a caller primed on the "number" convention (GitHub/idiomatic) must send index for PR tools but number for issue tools — inconsistent, and the shim only aliases indexnumber (one-directional), so sending number to pr_merge does not fill index.

Proposal

Finish the #38 normalization for the id field:

  1. Flip the PR tools (pr_merge, pr_get, pr_comment, pr_files_diff, and any other tool whose canonical is index) to canonical number, matching the issue tools.
  2. Make the shim bidirectional for numberindex (mirror what #38 did for namerepo), so both spellings resolve for every tool regardless of which the struct declares.
  3. Keep index as an accepted alias.

Acceptance

  • All issue AND PR tools advertise number in their schema.
  • index still resolves (back-compat) on every tool.
  • Bidirectional numberindex shim, mirroring namerepo.
  • Round-trip tests: number and index both resolve; explicit number wins.
  • task check passes.

Refs

  • Follow-up to #38 (v0.4.0). Shim: internal/tools/tool.go normalizeAliases.
## Context #38 (v0.4.0) made `repo` the canonical repo-identifier and kept `name` as an alias. Its body also named `number` as canonical for the issue/PR index. Most **issue** tools already use `number` canonical (with `index` aliased via the shim) — but the **PR tools do not**. ## Finding `pr_merge` (and other PR tools) advertise and read `index` as their canonical id field: ```go // internal/tools/pr_merge.go "index":{"type":"integer","minimum":1}, ... "required":["owner","repo","index"] ... Index int `json:"index"` ``` So a caller primed on the "`number`" convention (GitHub/idiomatic) must send `index` for PR tools but `number` for issue tools — inconsistent, and the shim only aliases `index`→`number` (one-directional), so sending `number` to `pr_merge` does **not** fill `index`. ## Proposal Finish the #38 normalization for the id field: 1. Flip the PR tools (`pr_merge`, `pr_get`, `pr_comment`, `pr_files_diff`, and any other tool whose canonical is `index`) to canonical `number`, matching the issue tools. 2. Make the shim **bidirectional** for `number`↔`index` (mirror what #38 did for `name`↔`repo`), so both spellings resolve for every tool regardless of which the struct declares. 3. Keep `index` as an accepted alias. ## Acceptance - [ ] All issue AND PR tools advertise `number` in their schema. - [ ] `index` still resolves (back-compat) on every tool. - [ ] Bidirectional `number`↔`index` shim, mirroring `name`↔`repo`. - [ ] Round-trip tests: `number` and `index` both resolve; explicit `number` wins. - [ ] `task check` passes. ## Refs - Follow-up to #38 (v0.4.0). Shim: `internal/tools/tool.go` `normalizeAliases`.
Author
Owner

Done in v0.4.1 (commit on main).

Scope was smaller than the issue estimated: on inspection, pr_merge was the only tool still advertising indexpr_get, pr_comment, pr_files_diff already use canonical number. So this was a one-file flip:

  • pr_merge schema property + required + struct field/tag indexnumber.
  • No shim change needed. The existing one-directional indexnumber alias already covers legacy index callers, and after the flip no tool has canonical index, so a bidirectional numberindex shim would be dead code — skipped it (min viable).
  • Test TestPRMergeNumberCanonical: schema advertises number, and both {"number":7} and {"index":7} resolve to /pulls/7/merge.
  • task check green.

Result: the id arg is number uniformly across all per-issue/PR tools; index remains an accepted alias. Deploying via CD.

Done in v0.4.1 (commit on `main`). **Scope was smaller than the issue estimated:** on inspection, `pr_merge` was the **only** tool still advertising `index` — `pr_get`, `pr_comment`, `pr_files_diff` already use canonical `number`. So this was a one-file flip: - `pr_merge` schema property + `required` + struct field/tag `index` → `number`. - **No shim change needed.** The existing one-directional `index`→`number` alias already covers legacy `index` callers, and after the flip no tool has canonical `index`, so a bidirectional `number`↔`index` shim would be dead code — skipped it (min viable). - Test `TestPRMergeNumberCanonical`: schema advertises `number`, and both `{"number":7}` and `{"index":7}` resolve to `/pulls/7/merge`. - `task check` green. Result: the id arg is `number` uniformly across all per-issue/PR tools; `index` remains an accepted alias. Deploying via CD.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mathias/gitea-mcp#45