fix(content-lane): reject a non-integer subnet netuid instead of coercing it to subnet 0 - #9782
Conversation
…cing it to subnet 0
`assessSubnetDocument`'s root-netuid check was `!Number.isInteger(Number(doc.netuid))`.
Number() coerces before the integer test, so values the message promises it
rejects slipped through: Number(null)===0, Number("")===0, Number([])===0,
Number(true)===1, Number("0x10")===16, Number(" 7 ")===7. A document with
`netuid: null` was accepted as subnet 0 and threaded into assessSurfaceEntry's
consistency check as if validated — a surface declaring `netuid: 0` then matched
it and could reach a decisive merge on the surface lane.
Validate the raw value type-first, mirroring the `!Array.isArray(doc.surfaces)`
sibling three lines below: reject unless `doc.netuid` is already a `number` that
`Number.isInteger` accepts and is non-negative (a netuid is a non-negative index;
0 stays valid). The summary text and `unsupported-shape` reason are unchanged, and
`const netuid` now reads the validated number directly with no coercion.
Closes JSONbored#9665
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-29 08:37:14 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9782 +/- ##
==========================================
+ Coverage 76.58% 76.69% +0.10%
==========================================
Files 282 283 +1
Lines 59464 59740 +276
Branches 6555 6673 +118
==========================================
+ Hits 45543 45819 +276
Misses 13639 13639
Partials 282 282
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Held for manual review: the gate and required CI are green, but GitHub reports this pull request's mergeable state as |
What & why
assessSubnetDocument(src/review/content-lane/registry-logic.ts) is the content lane's shape validator for a registry subnet file. Its root-netuid check was:Number()coerces before the integer test, so values the message promises it rejects slipped through:Number(null) === 0,Number("") === 0,Number([]) === 0,Number(true) === 1,Number("0x10") === 16,Number(" 7 ") === 7. A document with"netuid": nullwas therefore accepted as subnet 0 and threaded intoassessSurfaceEntry's consistency check as if it had been validated — its comment even relies on "the document validator already proved the root netuid is an integer". A surface declaringnetuid: 0then matched the fabricated root and could reach a decisivemergeon the surface lane.The fix
Validate the raw value type-first, mirroring the
!Array.isArray(doc.surfaces)sibling three lines below (which never coerces):A netuid is a non-negative index, so a negative integer is rejected too;
0stays valid. The failure summary andunsupported-shapereason code are unchanged (they're asserted by existing tests and rendered into the public close comment). No change toassessSurfaceEntryor any other branch.Tests (
test/unit/content-lane-registry-logic.test.ts)#9665case: each ofnull,"",true,[],[5],"7","0x10",1.5,-1,undefined→unsupported-shapewith the exact summary text. 9 of these fail againstmain.netuid: 0andnetuid: 64still produce a non-unsupported-shapeoutcome (not over-tightened).netuid: nulland a surface declaringnetuid: 0no longer reachesmerged— it fails onunsupported-shape.Validation
npm run typecheckgreen; the suite (171 tests) green.git diff --check <base> HEADclean; diff is two files, no route/schema/migration change.Closes #9665