Skip to content

Add additional details to serverSyncFailed error#4079

Draft
bjtitus wants to merge 1 commit into
trunkfrom
bjtitus/up-next-emptying/sentry-server-errors
Draft

Add additional details to serverSyncFailed error#4079
bjtitus wants to merge 1 commit into
trunkfrom
bjtitus/up-next-emptying/sentry-server-errors

Conversation

@bjtitus

@bjtitus bjtitus commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

| 📘 Part of: # |
|:---:|

Fixes PCIOS-

Includes additional details in the serverSyncFailed Sentry 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

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

Copilot AI review requested due to automatic review settings March 18, 2026 17:34
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 changeCount and syncReason for 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)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants