Repository navigation
Commit 63d22fa
authored
fix(publisher): record repository.id at init so renames stay resolvable (#1570)
Towards #1484
## Background
#1484 audited the `repository.url` of the 398 highest-graded remote
servers and
found 38 (9.5%) pointing at repositories that have since been renamed or
transferred. No hard 404s — GitHub's REST API follows the redirect — but
GraphQL
consumers resolve them as nonexistent (`Could not resolve to a
Repository`), so
the source link is broken for a real class of tooling, and it stays
broken once
the redirect eventually lapses.
## The gap this closes
`pkg/model/types.go` already defines the field that solves this:
```go
ID string `json:"id,omitempty" doc:"Repository identifier from the hosting service (e.g., GitHub repo ID). Owned and determined by the source forge. Should remain stable across repository renames and may be used to detect repository resurrection attacks …"`
```
Nothing populates it. `mcp-publisher init` builds the repository block
from
`detectRepoURL()` and writes `url` and `source` only, so in practice
every entry's
sole pointer at its source is a URL — and a URL is not a stable pointer.
This PR resolves the ID at init time and writes it alongside the URL. A
rename
after that point no longer loses the entry: the ID still identifies the
repository, and it also gives the "deleted and recreated" detection the
schema
doc already describes something to compare against.
## Scope and deliberate limits
- **One request, at scaffolding time.** Not in the publish path, so it
adds no
latency or GitHub rate-limit exposure to publishing.
- **Best effort.** `init` is otherwise fully offline. Being off the
network,
rate limited, or pointed at a private repo leaves the field empty rather
than
failing the command. `GITHUB_TOKEN` is used when set, mostly so a
rate-limited
developer still gets an ID.
- **GitHub only.** `repository.source` also allows `gitlab`, and
`detectRepoURL`
can produce a plain `git` source. Those return empty; GitLab's
equivalent
lookup is easy to add if you want it, but I did not want to guess at the
ID semantics for a forge the audit did not cover.
- Host matching is exact (`github.com`, optionally `www.`) so a
lookalike host
cannot get us to fetch an ID that belongs to somebody else. Covered by a
test.
## What this does **not** do
Two parts of #1484 are maintainer calls, not code I should pick
unilaterally, and
I have written them up on the issue rather than guessing here:
1. **Backfilling the 38 existing entries.** The registry's data is in
the
database, not this repo — `CLAUDE.md` is explicit that `data/seed.json`
is
local dev seed data and must not be used to publish. So a data fix
cannot
arrive as a PR to this repository at all; it needs an operator-run
migration,
and someone has to decide whether rewriting a publisher's
`repository.url`
without them re-publishing is acceptable.
2. **Publish-time behaviour on a redirecting URL** — reject, warn, or
accept and
record. `ValidateServerJSON` is currently pure and offline; the only
network
validation lives in `ValidatePublishRequest` behind
`cfg.EnableRegistryValidation`, and it returns a bare `error` with no
channel
for a warning even though `ValidationIssueSeverityWarning` exists
elsewhere.
Wiring a warning through is a real design decision about the publish
contract.
## Test
`cmd/publisher/commands/init_internal_test.go`:
- `TestParseGitHubOwnerRepo` — the URL shapes `detectRepoURL` actually
produces
(plain, `www.`, trailing slash, `.git`), plus the ones that must **not**
be
treated as GitHub: gitlab, a `github.com.evil.example` lookalike, a deep
`/tree/main/...` path, an owner with no repo.
- `TestDetectRepoID` — against an `httptest` stub: records the numeric
id and
requests `/repos/{owner}/{repo}`; and stays empty on 404 / non-GitHub
source /
empty URL, so a failed lookup can never fail `init`.
```
$ go test ./cmd/publisher/...
ok github.com/modelcontextprotocol/registry/cmd/publisher/auth 2.363s
ok github.com/modelcontextprotocol/registry/cmd/publisher/commands 4.838s
$ go build ./... # clean
$ gofmt -l cmd/ # clean
```
`golangci-lint` was not available in my environment, so that gate is
unverified
locally.
---------
Signed-off-by: Kush Zingade <[email protected]>1 parent 020fed3 commit 63d22fa
2 files changed
Lines changed: 197 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
| |||
247 | 260 | | |
248 | 261 | | |
249 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
250 | 347 | | |
251 | 348 | | |
252 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
0 commit comments