Conversation
…ker image building/pushing.
…common JSON utilities.
There was a problem hiding this comment.
Pull request overview
Adds GitHub Actions automation for pull-request CI (lint/build) and adjusts Docker image build/push behavior, alongside small HTTP response-write error handling improvements in the Go API.
Changes:
- Add a PR-triggered CI workflow to run
golangci-lintandgo build. - Update Docker workflow triggers/behavior to push images on
mainand version tags. - Add error handling for JSON encoding and health check response writes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/json/json.go |
Adds error handling around JSON encoding in the response helper. |
cmd/api.go |
Logs an error if writing the health check response fails. |
.github/workflows/docker.yml |
Removes PR trigger and makes image push unconditional for main/tag pushes. |
.github/workflows/ci.yml |
Introduces PR CI workflow for linting and build verification. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| w.WriteHeader(status) | ||
| json.NewEncoder(w).Encode(data) | ||
|
|
||
| if err := json.NewEncoder(w).Encode(data); err != nil { | ||
| http.Error(w, "Failed to encode response", http.StatusInternalServerError) | ||
| } |
There was a problem hiding this comment.
WriteHeader(status) is called before encoding the JSON. If Encode fails, the response status/headers are already committed and http.Error cannot reliably change the status to 500; it can also produce a partially-written/invalid JSON response. Consider encoding to a buffer first (then write status/body only on success), or change Write to return an error so callers can decide how to respond before headers are written.
…ker image building/pushing.