{"record":{"id":"d5c033c43ddbe993","repo":"jackwener/OpenCLI","slug":"returned-no-success-evidence","errorCode":null,"errorMessage":" returned no success evidence","messagePattern":" returned no success evidence","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/instagram/comment.js","lineNumber":48,"sourceCode":"      return await response.json();\n    } catch {\n      throw new Error(label + ' returned invalid JSON');\n    }\n  }\n  function getPostFromFeed(feed, label) {\n    if (!feed || typeof feed !== 'object' || !Array.isArray(feed.items)) {\n      throw new Error(label + ' returned malformed items payload');\n    }\n    if (idx >= feed.items.length) throw new Error('Post index ' + (idx + 1) + ' not found');\n    const post = feed.items[idx];\n    const pkRaw = post?.pk ?? post?.id;\n    const pk = typeof pkRaw === 'number' ? String(pkRaw) : (typeof pkRaw === 'string' ? pkRaw.trim() : '');\n    if (!/^\\\\d+$/.test(pk)) throw new Error(label + ' returned malformed post row');\n    return { pk };\n  }\n  function assertOkStatus(payload, label) {\n    if (!payload || typeof payload !== 'object' || payload.status !== 'ok') {\n      throw new Error(label + ' returned no success evidence');\n    }\n  }\n\n  // web_profile_info answers HTTP 400 for business accounts; feed-by-username needs no user id. See #2234.\n  const r1 = await fetch('https://www.instagram.com/api/v1/feed/user/' + encodeURIComponent(username) + '/username/?count=' + (idx + 1), opts);\n  if (!r1.ok) throw new Error(r1.status === 404 ? 'User not found: ' + username : 'HTTP ' + r1.status + ' - make sure you are logged in to Instagram');\n  const { pk } = getPostFromFeed(await readInstagramJson(r1, 'Instagram feed-by-username'), 'Instagram feed-by-username');\n\n  const csrf = document.cookie.match(/csrftoken=([^;]+)/)?.[1] || '';\n  const r2 = await fetch('https://www.instagram.com/api/v1/web/comments/' + pk + '/add/', {\n    method: 'POST', credentials: 'include',\n    headers: { ...headers, 'X-CSRFToken': csrf, 'Content-Type': 'application/x-www-form-urlencoded' },\n    body: 'comment_text=' + encodeURIComponent(commentText),\n  });\n  if (!r2.ok) throw new Error('Failed to comment: HTTP ' + r2.status);\n  assertOkStatus(await readInstagramJson(r2, 'Instagram comment'), 'Instagram comment');\n  return [{ status: 'Commented', user: username, text: commentText }];\n})()","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/comment.js#L30-L66","documentation":"assertOkStatus checks that the parsed comment-add response is an object with status === 'ok'. Instagram's web comments API confirms success via this field; any other shape or status means the comment was not posted, so the CLI throws '${label} returned no success evidence'.","triggerScenarios":"POST /api/v1/web/comments/{pk}/add/ returns 200 with status 'fail', a message like 'commenting is off', a duplicate-comment error, or an unexpected payload shape with no status field.","commonSituations":"Posting duplicate comments (spam filter); commenting on a post with comments disabled; account temporarily blocked from commenting; shadow-flagged session returning soft-failure bodies.","solutions":["Read the response message field for the specific reason (duplicate, blocked, comments disabled)","Deduplicate comment texts and add jitter/delays to avoid spam detection","Refresh session cookies / use a less-flagged account if comments are silently rejected","Confirm the post allows comments before attempting"],"exampleFix":"// before\nfunction assertOkStatus(payload, label) {\n  if (!payload || typeof payload !== 'object' || payload.status !== 'ok') {\n    throw new Error(label + ' returned no success evidence');\n  }\n}\n// after\nfunction assertOkStatus(payload, label) {\n  if (!payload || typeof payload !== 'object' || payload.status !== 'ok') {\n    throw new Error(label + ' returned no success evidence: ' + JSON.stringify(payload).slice(0, 200));\n  }\n}","handlingStrategy":"try-catch","validationCode":"const payload = await readInstagramJson(r2, 'comment');\nif (!payload || typeof payload !== 'object' || payload.status !== 'ok') {\n  console.error('Comment rejected:', JSON.stringify(payload));\n}","typeGuard":"function isSuccessPayload(p) {\n  return !!p && typeof p === 'object' && p.status === 'ok';\n}","tryCatchPattern":"try {\n  await runCommentPipeline(args);\n} catch (e) {\n  if (/no success evidence/.test(e.message)) {\n    console.error('Comment not accepted (duplicate, blocked, or comments disabled)');\n  } else throw e;\n}","preventionTips":["Vary comment text and add delays to avoid spam filters","Verify the post allows comments","Refresh cookies if comments silently fail","Check response message fields for the exact rejection reason"],"tags":["instagram","api-response","comment","validation"],"backgroundTag":"instagram-non-ok-status","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}