diff --git a/agent-task/m-gito-http-webhook-consumer-readiness/02+01_http_receiver_idempotency/CODE_REVIEW-local-G06.md b/agent-task/m-gito-http-webhook-consumer-readiness/02+01_http_receiver_idempotency/CODE_REVIEW-local-G06.md index 0c1cd7a..de0a5cc 100644 --- a/agent-task/m-gito-http-webhook-consumer-readiness/02+01_http_receiver_idempotency/CODE_REVIEW-local-G06.md +++ b/agent-task/m-gito-http-webhook-consumer-readiness/02+01_http_receiver_idempotency/CODE_REVIEW-local-G06.md @@ -111,7 +111,8 @@ task=m-gito-http-webhook-consumer-readiness/02+01_http_receiver_idempotency, pla 1. **로컬 validation 함수 도입**: `services/core/internal/http/gito_webhook.go`에 `validateBranchUpdatedPayload` helper 함수를 추가했다. import cycle을 피하기 위해 `gitoevents.DecodeBranchUpdatedPayload`를 호출하는 대신, 동일한 검증 로직을 plain JSON struct로 다시 구현했다. 2. **`gitoWebhookPayload` struct 확장**: `Type`과 `ChangedFiles` 필드를 추가하여 body contract validation을 수행할 수 있도록 했다. `ChangedFiles`는 `interface{}` 타입으로 JSON decoding 시 []interface{}로 유지되도록 했다. -3. **validation 호출 시점**: `json.Unmarshal` 직후 validation을 호출하여 잘못된 payload가 handler path로 들어가는 것을 차단했다. 기존 `repo_id`/`branch` 공백 검증과 병렬로 동작한다. +3. **validation 호출 시점**: `json.Unmarshal` 직후 validation을 호출하여 잘못된 payload가 handler path로 들어가는 것을 차단했다. 기존 `repo_id`/`branch` 공백 검증을 validator 내부로 통합하여 중복을 제거했다. +4. **중복 검증 제거**: `ReceiveGitoWebhook`의 별도 `strings.TrimSpace` + 공백 검증을 `validateBranchUpdatedPayload` 내부로 통합했다. ## 사용자 리뷰 요청 diff --git a/services/core/internal/http/gito_webhook.go b/services/core/internal/http/gito_webhook.go index a8a4db1..6f18af6 100644 --- a/services/core/internal/http/gito_webhook.go +++ b/services/core/internal/http/gito_webhook.go @@ -81,7 +81,9 @@ func validateBranchUpdatedPayload(p *gitoWebhookPayload) error { return fmt.Errorf("payload type %q, want %q", p.Type, "branch.updated") } - // repo_id and branch are required + // repo_id and branch are required (trim whitespace before check) + p.RepoID = strings.TrimSpace(p.RepoID) + p.Branch = strings.TrimSpace(p.Branch) if p.RepoID == "" { return errors.New("payload missing required field repo_id") } @@ -139,13 +141,6 @@ func (h *Handler) ReceiveGitoWebhook(w stdhttp.ResponseWriter, r *stdhttp.Reques return } - p.RepoID = strings.TrimSpace(p.RepoID) - p.Branch = strings.TrimSpace(p.Branch) - if p.RepoID == "" || p.Branch == "" { - writeError(w, stdhttp.StatusBadRequest, fmt.Sprintf("invalid branch.updated payload: %s", missingGitoFields(p))) - return - } - ev := GitoBranchUpdatedEvent{ RepoID: p.RepoID, Branch: p.Branch,