fix(network): return mainnet-only 404 before method gate on prefixed routes#2191
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2191 +/- ##
==========================================
- Coverage 93.25% 93.23% -0.02%
==========================================
Files 51 52 +1
Lines 8076 8127 +51
Branches 2962 2981 +19
==========================================
+ Hits 7531 7577 +46
- Misses 92 96 +4
- Partials 453 454 +1
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review — safe to merge
✅ Approved — safe to merge Review summary
Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. The PR correctly hoists the `isMainnetOnlyApiPath` guard ahead of the read-only method gate in `handleNetworkScopedRequest` (`workers/api.mjs`), so POST/PUT/DELETE to mainnet-only prefixed paths (e.g., `/api/v1/testnet/graphql`) now return 404 + `meta.network` instead of 405. The `isApiPath` extraction is a clean DRY improvement. Test coverage for the targeted fix is solid: GET and POST mainnet-only → 404, POST non-mainnet-only → 405. Nits (4)
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
isMainnetOnlyApiPathbefore the read-only method gate inhandleNetworkScopedRequest.meta.networkas GET.Closes #2190
Why
Agents probing
/api/v1/testnet/graphqlwith POST see 405 instead of the documented mainnet-only 404, diverging from sibling GET routes and from bare mainnet behavior.Test plan
npm test -- tests/network-routing.test.mjsPOST /api/v1/testnet/graphql→ 404, mainnet-only message,meta.network === "testnet"GETon same path unchanged (404 mainnet-only)