{"record":{"id":"09d03ea9431b422b","repo":"TryGhost/Ghost","slug":"failed-to-like-comment","errorCode":null,"errorMessage":"Failed to like comment","messagePattern":"Failed to like comment","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/comments-ui/src/utils/api.ts","lineNumber":282,"sourceCode":"                        return res.json();\n                    } else {\n                        throw new Error('Failed to read comment');\n                    }\n                });\n            },\n            like({comment}: {comment: {id: string}}) {\n                const url = endpointFor({type: 'members', resource: `comments/${comment.id}/like`});\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 like comment');\n                    }\n                });\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';","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/TryGhost/Ghost/blob/47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe/apps/comments-ui/src/utils/api.ts#L264-L300","documentation":"comments.like() POSTs to /members/api/comments/{comment.id}/like to register a like. It returns the literal string 'Success' on res.ok, or throws this error on non-ok. No body is sent. This is an idempotent-style action but the backend distinguishes first-like from already-liked states.","triggerScenarios":"The POST returns 4xx/5xx. The member is not authenticated (401), already liked the comment (may be 409 or 400 depending on backend), the comment was deleted (404), the member is banned (403), or rate limiting applies (429).","commonSituations":"A member double-clicks the like button and the second request conflicts. A member's session expired and the like silently fails. The comment was removed by a moderator but the button is still rendered.","solutions":["Check the Network tab POST response status and body.","Optimistically update the UI but roll back on error; disable the button during the request to prevent double-submits.","If 401, prompt re-authentication; if 404, remove the comment locally.","Handle 'already liked' (if the backend returns it distinctly) by syncing to the liked state rather than showing an error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// optimistic UI with rollback\nsetLiked(true);\ntry {\n  await api.comments.like({comment});\n} catch (e) {\n  setLiked(false); // roll back\n  if (e instanceof Error && e.message === 'Failed to like comment') {\n    // re-auth or inform user\n  }\n}","preventionTips":["Disable the like button during the POST to prevent double-clicks and 429s.","Use optimistic UI with rollback so the user sees immediate feedback.","Handle 401 by re-establishing the member session before retrying."],"tags":["network","fetch","comments-ui","like","reaction"],"backgroundTag":null,"analyzedSha":"47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe","analyzedAt":"2026-08-13T01:25:26.651Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}