fix(spawn): compare the no-mistakes delivery target by identity, not string equality #8
Loading…
Reference in a new issue
No description provided.
Delete branch "fm/fm-guard-compares-wrong-field"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The defect
The delivery-target guard added in #7 refuses every Forgejo project in the fleet, including this repository, on a mismatch that is not real.
no-mistakes initstores the upstream URL with its userinfo masked — the literal stringredactedin place of the SSH username:The guard compared those with string equality, so it failed on a redaction artifact.
Why this is a tool defect, not stale data
eject+initstill wroteredacted. Upgrading does not fix it.codelightescapes only because its GitHub URL is SCP-style with nossh://userinfo component.originpointing at the correct Forgejo URL.So the stored column is a masked display value, not the target the tool pushes to.
The fix
Compare by identity — host, port and repository path — and ignore userinfo. Both
ssh://user@host:port/pathand SCP-stylegit@host:pathforms are normalised; an unparseable URL refuses rather than passes, preserving the guard's fail-closed design.The literal mask string is deliberately not special-cased: matching it would break the moment the tool changes its mask, and would silently accept a genuinely wrong username.
What still refuses
The protection #7 was written for is intact — a GitHub host where Forgejo is expected, a wrong repository path, an unrecorded target, an unreadable database, and an unparseable URL all still refuse the spawn.
Tests
This function shipped with no coverage, which is how it went out broken.
Correction to an earlier claim in this description: only one test was genuinely red before the fix —
test_no_mistakes_masked_userinfo_accepts_spawn. The other spawn-level cases already passed pre-fix, because plain string equality is over-strict rather than under-strict: every refusal case it should reject, it already rejected. Those tests are regression guards for the new normalisation, not reproductions of the bug.tests/fm-nm-target-lib.test.shcovers new code that had no pre-fix equivalent to be red against.That distinction matters: a test that passes against broken code proves nothing about the bug, and describing all of them as red would have overstated the evidence.