Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(handler): validate skill id UUID at request boundary (#3025)
Tom Qiaob9602adabe32
diff --git a/server/internal/handler/skill.go b/server/internal/handler/skill.goindex 60ada4ca7d..fc30f8de53 100644--- a/server/internal/handler/skill.go+++ b/server/internal/handler/skill.go@@ -196,8 +196,13 @@ func (h *Handler) loadSkillForUser(w http.ResponseWriter, r *http.Request, id streturn db.Skill{}, false}+ skillUUID, ok := parseUUIDOrBadRequest(w, id, "skill id")+ if !ok {+ return db.Skill{}, false+ }+skill, err := h.Queries.GetSkillInWorkspace(r.Context(), db.GetSkillInWorkspaceParams{- ID: parseUUID(id),+ ID: skillUUID,WorkspaceID: parseUUID(workspaceID),})if err != nil {diff --git a/server/internal/handler/skill_list_test.go b/server/internal/handler/skill_list_test.goindex a5e931abdb..2dfa458f03 100644--- a/server/internal/handler/skill_list_test.go+++ b/server/internal/handler/skill_list_test.go@@ -111,6 +111,22 @@ func TestListAgentSkills_OmitsContent(t *testing.T) {}}+// TestGetSkill_MalformedUUIDReturns400 guards the handler UUID parsing+// convention (CLAUDE.md → "Backend Handler UUID Parsing Convention"): raw+// `id` URL params on the request boundary must be validated with+// parseUUIDOrBadRequest, not the panic-prone parseUUID. Before the fix+// the malformed input panicked in MustParseUUID and was rescued by the+// chi Recoverer middleware as a 500.+func TestGetSkill_MalformedUUIDReturns400(t *testing.T) {+ w := httptest.NewRecorder()+ req := newRequest("GET", "/api/skills/not-a-uuid", nil)+ req = withURLParam(req, "id", "not-a-uuid")+ testHandler.GetSkill(w, req)+ if w.Code != 400 {+ t.Fatalf("GetSkill malformed uuid: expected 400, got %d: %s", w.Code, w.Body.String())+ }+}+// insertHandlerTestSkill writes a skill row directly via SQL and registers a// cleanup hook. We bypass the create handler to keep the test focused on the// list/detail wire shape and to make it easy to inject a large body.