Skip to content

C6 [CRIT]: unwind A13 over-fit on label create 422#3

Merged
mfwolffe merged 2 commits into
trunkfrom
c6/label-create-422-fix
May 17, 2026
Merged

C6 [CRIT]: unwind A13 over-fit on label create 422#3
mfwolffe merged 2 commits into
trunkfrom
c6/label-create-422-fix

Conversation

@espadonne
Copy link
Copy Markdown
Contributor

Summary

A13 ("friendly 409 on pre-seeded labels") taught label create to render a 422 as label "<name>" already exists; pass --force to overwrite. The audit caught the over-fit: every 422 — length, charset, color shape — is now reported as already-exists. Real validation failures are silently rewritten as uniqueness conflicts, pushing users toward --force for problems --force cannot fix.

C-audit reproducer (pre-fix):

shithub label create -R owner/r "   " --color abc123
# → label "   " already exists on owner/r; pass --force to overwrite
# (server actually said: 422 issues: label name length 1-50)

shithub label create -R owner/r "$(printf x%.0s {1..60})" --color abc123
# → label "xxxxx…" already exists; pass --force to overwrite
# (server actually said: 422 name too long)

Fix

pkg/cmd/label/create/create.go:isAlreadyExists:

  • 409 → always uniqueness (clear status semantic)
  • 422 → only if the server message contains "already taken", "already exists", or "duplicate"
  • All other 422s fall through to the raw server error path

Server's actual uniqueness message (from shithub/.docs and direct API probing) is label name already taken on this repo; the substring check is robust to phrasing tweaks.

Test plan

  • TestCreate409TreatedAsConflict — 409 maps to friendly error.
  • TestCreateUniquenessConflictNoForce — 422 with "already taken" maps to friendly error.
  • TestCreate422LengthErrorNotMisclassifiedregression test for C6: 422 with "length 1-50" propagates the raw message; never mentions --force.
  • TestCreateForceFallsBackToEdit--force PATCH path still works on uniqueness conflicts.
  • make ci green locally.

@mfwolffe mfwolffe merged commit fd250d6 into trunk May 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants