Skip to content

[TT-15507] Reverting /hello endpoint to always return 200 status code #7282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 11, 2025

Conversation

mativm02
Copy link
Contributor

@mativm02 mativm02 commented Aug 7, 2025

TT-15507
Summary Revert changes to the "/hello" health check endpoint
Type Bug Bug
Status In Dev
Points N/A
Labels -

User description

  • The /hello (liveness) endpoint is reverted to always respond with HTTP 200, regardless of internal health check status.
  • Health status calculation in the liveness handler is refactored and simplified—now based solely on the number of failed checks (failCount), removing the previous "critical failure" logic.
  • Error handling is added for JSON encoding errors in the readiness handler, so encoding issues are now logged.

@buger
Copy link
Member

buger commented Aug 7, 2025

💔 The detected issue is not in one of the allowed statuses 💔

Detected Status Open
Allowed Statuses In Dev,In Code Review,Ready for Testing,In Test,In Progress,In Review ✔️

Please ensure your jira story is in one of the allowed statuses

Copy link
Contributor

github-actions bot commented Aug 7, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Changed HTTP Status Code

The /hello (liveness) endpoint now always returns HTTP 200, regardless of health check failures. This change should be validated to ensure it aligns with intended system behavior and does not mask underlying issues from monitoring systems.

w.WriteHeader(http.StatusOK)
Error Handling Improvement

Error handling for JSON encoding has been added to the readiness handler. Confirm that this logging is sufficient and that no additional error response should be sent to the client in case of encoding failure.

err := json.NewEncoder(w).Encode(res)
if err != nil {
	mainLog.Warning(fmt.Sprintf("[Readiness] Could not encode response, error: %s", err.Error()))
}

Copy link
Contributor

github-actions bot commented Aug 7, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle empty health checks correctly

The use of case len(checks): in the switch statement will never match, since
failCount cannot equal len(checks) unless all checks fail. However, if checks is
empty, this will incorrectly set status to Fail. Add a guard to handle the empty
checks case to avoid misclassifying the health status.

gateway/health_check.go [192-209]

 for _, v := range checks {
 	if v.Status == Fail {
 		failCount++
 	}
 }
 
 var status HealthCheckStatus
 
-switch failCount {
-case 0:
-	status = Pass
-
-case len(checks):
+if len(checks) == 0 {
 	status = Fail
-
-default:
-	status = Warn
+} else {
+	switch failCount {
+	case 0:
+		status = Pass
+	case len(checks):
+		status = Fail
+	default:
+		status = Warn
+	}
 }
Suggestion importance[1-10]: 8

__

Why: This suggestion correctly identifies a subtle bug: if checks is empty, the current logic would incorrectly set the status to Fail due to the case len(checks): branch. The improved code adds a guard for the empty slice, ensuring the health status is classified accurately, which is important for correct system behavior.

Medium

Copy link
Contributor

github-actions bot commented Aug 7, 2025

API Changes

no api changes detected

@ilijabojanovic ilijabojanovic enabled auto-merge (squash) August 11, 2025 08:18
@buger
Copy link
Member

buger commented Aug 11, 2025

I'm a bot and I 👍 this PR title. 🤖

Copy link

@lghiur lghiur disabled auto-merge August 11, 2025 16:02
@lghiur lghiur merged commit 918476f into release-5.8.4 Aug 11, 2025
67 of 68 checks passed
@lghiur lghiur deleted the TT-15507-release-5.8.4 branch August 11, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants