Add additional details to serverSyncFailed error#4079
Draft
bjtitus wants to merge 1 commit into
Draft
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
There was a problem hiding this comment.
Pull request overview
Improves observability of UpNextSyncTask failures by capturing additional request/response context when the Up Next sync call returns an unexpected HTTP status.
Changes:
- Captures
changeCountandsyncReasonfor failed Up Next sync attempts. - Logs a truncated server response body on sync failure.
- Adds additional fields (
httpStatus,changeCount,requestBytes,syncReason,responseBody) to error reporting context.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+67
to
+78
| let responseBody = response.flatMap { String(data: $0, encoding: .utf8) } | ||
| let truncatedBody = responseBody.map { String($0.prefix(500)) } ?? "nil" | ||
| FileLog.shared.addMessage("UpNextSyncTask: Unable to sync with server got status \(httpStatus), response: \(truncatedBody)") | ||
| let syncError = UpNextSyncError.serverSyncFailed(httpStatus: httpStatus) | ||
| ServerConfig.shared.errorLogger?.log(error: syncError, context: ["source": "upnext_sync", "httpStatus": "\(httpStatus)"]) | ||
| ServerConfig.shared.errorLogger?.log(error: syncError, context: [ | ||
| "source": "upnext_sync", | ||
| "httpStatus": "\(httpStatus)", | ||
| "changeCount": "\(changeCount)", | ||
| "requestBytes": "\(data.count)", | ||
| "syncReason": syncReason, | ||
| "responseBody": truncatedBody | ||
| ]) |
Comment on lines
+67
to
+69
| let responseBody = response.flatMap { String(data: $0, encoding: .utf8) } | ||
| let truncatedBody = responseBody.map { String($0.prefix(500)) } ?? "nil" | ||
| FileLog.shared.addMessage("UpNextSyncTask: Unable to sync with server got status \(httpStatus), response: \(truncatedBody)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
| 📘 Part of: # |
|:---:|
Fixes PCIOS-
Includes additional details in the
serverSyncFailedSentry error to help diagnose what's causing 500s. There are a surprising number of these on watchOS and most are probably network connection errors.To test
Checklist
CHANGELOG.mdif necessary.