MCPcopy
hub / github.com/multica-ai/multica / parseUUIDOrBadRequest

Function parseUUIDOrBadRequest

server/internal/handler/handler.go:317–324  ·  view source on GitHub ↗

parseUUIDOrBadRequest validates a UUID string sourced from user input (URL params, request body, headers). On invalid input it writes a 400 response and returns ok=false; callers must return immediately. Use this anywhere a malformed UUID would otherwise reach a write query (DELETE / UPDATE) — the

(w http.ResponseWriter, s, fieldName string)

Source from the content-addressed store, hash-verified

315// (DELETE / UPDATE) — the silent zero-UUID behavior of the old ParseUUID
316// caused real silent-data-loss bugs (#1661).
317func parseUUIDOrBadRequest(w http.ResponseWriter, s, fieldName string) (pgtype.UUID, bool) {
318 u, err := util.ParseUUID(s)
319 if err != nil {
320 writeError(w, http.StatusBadRequest, "invalid "+fieldName)
321 return pgtype.UUID{}, false
322 }
323 return u, true
324}
325
326func parseUUIDSliceOrBadRequest(w http.ResponseWriter, ids []string, fieldName string) ([]pgtype.UUID, bool) {
327 uuids := make([]pgtype.UUID, len(ids))

Callers 15

InitiateListModelsMethod · 0.85
DaemonRegisterMethod · 0.85
DaemonHeartbeatMethod · 0.85
GetIssueGCCheckMethod · 0.85
GetChatSessionGCCheckMethod · 0.85
GetWorkspaceMethod · 0.85
UpdateWorkspaceMethod · 0.85
ListMembersWithUserMethod · 0.85

Calls 1

writeErrorFunction · 0.70

Tested by

no test coverage detected