fix: require pinHeader pinCount to be a positive integer (#756)#757
fix: require pinHeader pinCount to be a positive integer (#756)#757DPS0340 wants to merge 1 commit into
Conversation
|
Withdrawing this one on queue grounds rather than anything about the change itself. I counted my own output across every repo I contribute to. Among PRs a maintainer actually decided, 57% merged — but 94% of what I have opened has never been looked at by a human at all. The constraint was never quality; I was handing out more review work than anyone could absorb. This PR fixes an issue I filed myself, which is the shape most of that volume took: find something, report it, fix it, and hand a maintainer work nobody asked for. I am closing the self-originated ones across every repo and keeping only those that answer someone else's bug report. The branch stays up and the issue stays open, so nothing is lost. If this one is actually wanted, say so and I will reopen it. Sorry for the noise. |
Fixes #756. Independent of my #755 (different file) — either order.
What was wrong
pinCount: z.number()accepted fractional, zero, negative and infinite values. The fractional case is the damaging one — it produces a header whose ports and pads disagree, silently:pinCountsource_portsEvery whole number agrees; every fractional one leaves a pad with no port behind it. That renders and exports without complaint.
Zero and negative counts fail too, but later and misleadingly — they surface as
pcb_missing_footprint_error, which points at the footprint when the mistake was the count.The fix
.int()catches the fractional case,.positive()catches0and negatives, and together they also rejectInfinity(whichz.number()lets through — it only excludesNaN).This is the idiom the repo already uses:
lib/components/analogacsweepsimulation.tshasz.number().int().positive()forsampleCountandsamplesPerInterval. No new convention.Scope
pinCountonly. I checked the neighbouring schemas rather than assuming — it's the sole barez.number()inpin-header.ts, andbreakout.ts/chip.tshave no comparable count field taking a raw number. Anything broader would be speculative.Tests
tests/pin-header-pin-count.test.ts, six tests pinning both directions:1,4,402.5,3.70,-4NaN,InfinitypinCountat allpinCount: 88unchangedThe last two rows are the guard rails: a change that made the field optional, or that coerced values, would break them while a bare "rejects bad input" check would not.
Bite-proofed: reverting only
lib/components/pin-header.tstakes the file from 6 pass to 3 pass / 3 fail.Verification
bun test: 389 pass / 0 fail (baseline onmainis 383 pass / 0 fail; +6 new).bunx tsc --noEmitclean,bun run format:checkclean.