diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c44d203..9905de9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,9 +25,10 @@ jobs: # Setup SSH mkdir -p ~/.ssh - echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key + chmod 700 ~/.ssh + echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key - ssh-keyscan -p $SSH_PORT -H $SSH_HOST >> ~/.ssh/known_hosts + ssh-keyscan -p $SSH_PORT -H $SSH_HOST >> ~/.ssh/known_hosts 2>/dev/null # Pull latest code and restart service echo "🔄 Pulling latest code and restarting service..." @@ -70,7 +71,7 @@ jobs: echo "🔍 Verifying deployment..." # Setup SSH for verification - echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key + echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key # Test health endpoint diff --git a/internal/handlers/errors.go b/internal/handlers/errors.go index 9db06bd..f83f689 100644 --- a/internal/handlers/errors.go +++ b/internal/handlers/errors.go @@ -79,7 +79,9 @@ func HandleError(w http.ResponseWriter, r *http.Request, err error) { response.Message = appErr.Message } - json.NewEncoder(w).Encode(response) + if err := json.NewEncoder(w).Encode(response); err != nil { + log.Printf("ERROR encoding JSON response: %v", err) + } return } @@ -93,7 +95,9 @@ func HandleError(w http.ResponseWriter, r *http.Request, err error) { message = "An error occurred. Please try again later." } - w.Write([]byte("