--- id: "bug-1782" status: "fixed" status_updated: "2026-09-24" status_note: "" component: "apiserver" severity: "unknown" timestamp: "2026-09-07T08:40:00Z" last_seen: "2026-09-19T09:00:00Z" occurrences: 1 files: ["src/frontend/apiserver/backend/convert_pure.go (ParseHumanJobID", "new)", "src/frontend/apiserver/controllers/jobs.go (ControlJobByID)"] tags: ["apiserver", "api-design", "job-control", "human-readable-id", "gitea-45", "enhancement", "live-verified"] related: ["bug-1781"] legacy: true gitea_issue: 45 gitea_synced_status: "fixed" --- # bug-1782: Not a defect -- API ergonomics follow-up discussed while fixing bug-1781/gitea#45. The job control… ## Description Not a defect -- API ergonomics follow-up discussed while fixing bug-1781/gitea#45. The job control REST endpoint (`/xce/v1/jobs/{jobids}/control`) only accepted the packed numeric job ID; xcecli already translates the human-readable form (e.g. `1-0-1788768547-0`, as printed by `jobs list`) to that numeric form client-side (format.ToAPIJobID) before calling the API, so a caller hitting the endpoint directly (not through xcecli) had to reimplement that bit-packing itself. ## Environment _Not recorded (migrated from buglog.json)._ ## Reproduction _Not recorded (migrated from buglog.json)._ ## Root cause N/A -- enhancement, not a bug. Existing numeric-only behavior was correct and intentional. ## Fix ADDED (2026-09-07), additive/backward-compatible -- the numeric form is untouched and still works exactly as before. Added ParseHumanJobID(s string) (uint64, bool) to convert_pure.go: parses a plain human-readable job ID ("{cluster}-{apiserver}-{timestamp}-{sequence}", no array brackets -- controllers/jobs.go's parseArrayName already strips any "[idx]" suffix before this runs) back into the packed numeric ID, reusing the bit-layout constants this file already duplicates from xcecli/common/format/jobid.go for the read path (FormatJobID/ExtractArrayBaseID). Works correctly for both a plain job's own ID and an array child's dash-quad prefix (verified equal to ExtractArrayBaseID(original) in the array case -- the two enums are NOT ambiguous here, unlike bug-1781). ControlJobByID (jobs.go) now falls back to ParseHumanJobID when jobid.KeyID isn't numeric, before erroring; numeric IDs skip this path entirely. TDD: TestParseHumanJobID_NonArrayRoundTripsWithFormatJobID, TestParseHumanJobID_ArrayChildPrefixMatchesBaseID, TestParseHumanJobID_RejectsNumeric, TestParseHumanJobID_RejectsGarbage (convert_test.go), passing under CGO_ENABLED=0 go test. Verified with a full /xce-build apiserver asan --incremental (exit 0). LIVE-VERIFIED: against the same deployed cluster used for bug-1781, called POST /xce/v1/jobs/{jobids}/control directly via curl with the URL-encoded human-readable ID (bypassing xcecli's own translation entirely) and confirmed the job was correctly found and killed (HTTP 202, job removed from listing). ## Verification _Not recorded (migrated from buglog.json)._ ## References - Related: bug-1781 - Gitea: #45