{"record":{"id":"840ee03f10bce9fb","repo":"TryGhost/Ghost","slug":"failed-to-unlike-comment","errorCode":null,"errorMessage":"Failed to unlike comment","messagePattern":"Failed to unlike comment","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/comments-ui/src/utils/api.ts","lineNumber":302,"sourceCode":"                });\n            },\n            unlike({comment}: {comment: {id: string}}) {\n                const body = {\n                    comments: [comment]\n                };\n                const url = endpointFor({type: 'members', resource: `comments/${comment.id}/like`});\n                return makeRequest({\n                    url,\n                    method: 'DELETE',\n                    headers: {\n                        'Content-Type': 'application/json'\n                    },\n                    body: JSON.stringify(body)\n                }).then(function (res) {\n                    if (res.ok) {\n                        return 'Success';\n                    } else {\n                        throw new Error('Failed to unlike comment');\n                    }\n                });\n            },\n            dislike({comment}: {comment: {id: string}}) {\n                const url = endpointFor({type: 'members', resource: `comments/${comment.id}/dislike`});\n                return makeRequest({\n                    url,\n                    method: 'POST',\n                    headers: {\n                        'Content-Type': 'application/json'\n                    }\n                }).then(function (res) {\n                    if (res.ok) {\n                        return 'Success';\n                    } else {\n                        throw new Error('Failed to dislike comment');\n                    }\n                });","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/TryGhost/Ghost/blob/47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe/apps/comments-ui/src/utils/api.ts#L284-L320","documentation":"comments.unlike() DELETEs /members/api/comments/{comment.id}/like with a body of {comments: [comment]} to remove a like. Returns 'Success' on ok, throws on non-ok. The DELETE-with-body pattern is unusual but matches this API's convention.","triggerScenarios":"The DELETE returns 4xx/5xx. The member did not previously like the comment (may be 404/409), the session expired (401), the comment was deleted (404), or the server errors (5xx).","commonSituations":"A member removes a like on a comment that was deleted server-side. A session expiry mid-session. A race where the like was already removed by another tab/request.","solutions":["Check the Network tab DELETE response status.","Optimistically toggle the UI and revert on error; debounce the button.","If 404, sync local state to 'not liked' since the like or comment no longer exists.","If 401, re-authenticate before retrying."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"setLiked(false);\ntry {\n  await api.comments.unlike({comment});\n} catch (e) {\n  setLiked(true); // roll back\n  if (e instanceof Error && e.message === 'Failed to unlike comment') {\n    // sync state from server\n  }\n}","preventionTips":["Disable the button during the DELETE to prevent duplicate toggles.","Use optimistic UI with rollback.","On 404, sync local state to 'not liked' since the target is gone."],"tags":["network","fetch","comments-ui","unlike","reaction"],"backgroundTag":null,"analyzedSha":"47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe","analyzedAt":"2026-08-13T01:25:26.651Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}