-
Notifications
You must be signed in to change notification settings - Fork 7
Improve error logging for 500/ISE scenarios #129
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -66,7 +66,10 @@ func GetEstbFirmwareSwuBseHandler(w http.ResponseWriter, r *http.Request) { | |||||||||
| return | ||||||||||
| } | ||||||||||
| estbFirmwareRuleBase := dataef.NewEstbFirmwareRuleBaseDefault() | ||||||||||
| bseConfiguration, _ := estbFirmwareRuleBase.GetBseConfiguration(ip) | ||||||||||
| bseConfiguration, err := estbFirmwareRuleBase.GetBseConfiguration(ip) | ||||||||||
| if err != nil { | ||||||||||
| log.Errorf("GetEstbFirmwareSwuBseHandler failed to get BSE configuration: %v", err) | ||||||||||
| } | ||||||||||
| if bseConfiguration == nil { | ||||||||||
| xhttp.WriteXconfResponseAsText(w, 404, []byte("\"<h2>404 NOT FOUND</h2>\"")) | ||||||||||
| return | ||||||||||
|
|
@@ -125,7 +128,10 @@ func GetEstbFirmwareSwuHandler(w http.ResponseWriter, r *http.Request) { | |||||||||
| } | ||||||||||
|
|
||||||||||
| firmwareConfigResponse := sharedef.CreateFirmwareConfigFacadeResponse(*evaluationResult.FirmwareConfig) | ||||||||||
| response, _ := util.JSONMarshal(firmwareConfigResponse) | ||||||||||
| response, err := util.JSONMarshal(firmwareConfigResponse) | ||||||||||
| if err != nil { | ||||||||||
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetEstbFirmwareSwuHandler failed to marshal firmware config response: %v", err) | ||||||||||
|
||||||||||
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetEstbFirmwareSwuHandler failed to marshal firmware config response: %v", err) | |
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetEstbFirmwareSwuHandler failed to marshal firmware config response: %v", err) | |
| xhttp.Error(w, http.StatusInternalServerError, common.NotOK) | |
| return |
Copilot
AI
Mar 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Eval(...) returns an error, the function may still return 404 Not Found (if evaluationResult is nil/invalid), conflating internal evaluation failures with genuine 'not found' cases. If err != nil, consider returning 500 Internal Server Error (and an appropriate error body) to accurately reflect an evaluation failure.
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,8 @@ import ( | |||||||||||||||
| "github.com/rdkcentral/xconfwebconfig/shared" | ||||||||||||||||
| coreef "github.com/rdkcentral/xconfwebconfig/shared/estbfirmware" | ||||||||||||||||
| "github.com/rdkcentral/xconfwebconfig/shared/firmware" | ||||||||||||||||
|
|
||||||||||||||||
|
||||||||||||||||
Copilot
AI
Mar 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetDefaultPercentFilterValueOneDB returns (nil, err) on DB failures. When that happens, filterValue is nil here, but the code immediately dereferences filterValue.EnvModelPercentages, filterValue.Whitelist, etc., which will panic. Add a nil guard (e.g., return false / treat as 0% / default behavior) when filterValue == nil after the call fails.
| } | |
| } | |
| if filterValue == nil { | |
| // On DB failure or missing default filter value, avoid panicking and | |
| // fall back to allowing firmware output (no percent-based blocking). | |
| return true | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -247,6 +247,8 @@ func GetFeatureControlSettingsHandler(w http.ResponseWriter, r *http.Request) { | |||||||||
| featureControl.FeatureResponses = append(featureControl.FeatureResponses, extraFeatureResponses...) | ||||||||||
| if bbytes, err := json.Marshal(extraFeatureResponses); err == nil { | ||||||||||
| rfcPostProc = string(bbytes) | ||||||||||
| } else { | ||||||||||
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetFeatureControlSettingsHandler failed to marshal post-processing response: %v", err) | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
@@ -292,7 +294,10 @@ func GetFeatureControlSettingsHandler(w http.ResponseWriter, r *http.Request) { | |||||||||
| featureControlMap := &map[string]rfc.FeatureControl{ | ||||||||||
| "featureControl": *featureControl, | ||||||||||
| } | ||||||||||
| response, _ := util.XConfJSONMarshal(featureControlMap, true) | ||||||||||
| response, err := util.XConfJSONMarshal(featureControlMap, true) | ||||||||||
| if err != nil { | ||||||||||
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetFeatureControlSettingsHandler failed to marshal feature control response: %v", err) | ||||||||||
|
||||||||||
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetFeatureControlSettingsHandler failed to marshal feature control response: %v", err) | |
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetFeatureControlSettingsHandler failed to marshal feature control response: %v", err) | |
| xhttp.WriteXconfResponseWithHeaders(w, headers, http.StatusInternalServerError, []byte(`{"error":"internal server error"}`)) | |
| return |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -131,7 +131,10 @@ func GetLogUploaderSettings(w http.ResponseWriter, r *http.Request, isTelemetry2 | |||||||||||||
| if telemetryProfile == nil { | ||||||||||||||
| xhttp.WriteXconfResponseAsText(w, 404, []byte("\"<h2>404 NOT FOUND</h2><div> telemetry profile not found</div>\"")) | ||||||||||||||
| } else { | ||||||||||||||
| response, _ := util.JSONMarshal(*telemetryProfile) | ||||||||||||||
| response, err := util.JSONMarshal(*telemetryProfile) | ||||||||||||||
| if err != nil { | ||||||||||||||
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetLogUploaderSettings failed to marshal telemetry profile: %v", err) | ||||||||||||||
|
||||||||||||||
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetLogUploaderSettings failed to marshal telemetry profile: %v", err) | |
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetLogUploaderSettings failed to marshal telemetry profile: %v", err) | |
| xhttp.Error(w, http.StatusInternalServerError, common.NotOK) | |
| return |
Copilot
AI
Mar 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If marshaling the settings response fails, the handler still returns HTTP 200 with a potentially empty/invalid response body. Consider returning a 500 (and exiting) when util.JSONMarshal fails so clients don’t receive a successful status with an invalid payload.
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetLogUploaderSettings failed to marshal settings response: %v", err) | |
| log.WithFields(common.FilterLogFields(fields)).Errorf("GetLogUploaderSettings failed to marshal settings response: %v", err) | |
| xhttp.WriteXconfResponseAsText(w, http.StatusInternalServerError, []byte("\"Internal Server Error\"")) | |
| return |
Copilot
AI
Mar 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above: a marshal failure still results in HTTP 200. Please return an error status (e.g., 500) and avoid emitting a successful response when serialization fails.
| } | |
| xhttp.WriteXconfResponse(w, 200, response) | |
| xhttp.WriteXconfResponse(w, http.StatusInternalServerError, []byte("internal server error")) | |
| return | |
| } | |
| xhttp.WriteXconfResponse(w, http.StatusOK, response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If GetBseConfiguration returns an error (e.g., DB failure), this logs the error but then returns a 404 when bseConfiguration is nil. That conflates internal failures with ‘not found’. Consider returning 500 on err != nil (and only returning 404 when err == nil and the config is truly absent).