{"record":{"id":"5146975c579e95ed","repo":"jackwener/OpenCLI","slug":"open-the-post-in-a-logged-in-browser-session-and-r","errorCode":null,"errorMessage":"Open the post in a logged-in browser session and retry","messagePattern":"Open the post in a logged-in browser session and retry","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/download.js","lineNumber":320,"sourceCode":"    const unwrapped = unwrapEvaluateResult(result);\n    if (!unwrapped || typeof unwrapped !== 'object' || Array.isArray(unwrapped)) {\n        throw new CommandExecutionError('Failed to fetch Instagram media metadata');\n    }\n    if (typeof unwrapped.ok !== 'boolean') {\n        throw new CommandExecutionError('Instagram media metadata returned malformed result');\n    }\n    return unwrapped;\n}\nfunction handleFetchFailure(result) {\n    const message = result.error || 'Instagram media fetch failed';\n    if (result.errorCode === 'AUTH_REQUIRED') {\n        throw new AuthRequiredError('instagram.com', message);\n    }\n    if (result.errorCode === 'RATE_LIMITED') {\n        throw new CliError('RATE_LIMITED', message, 'Wait a few minutes and retry, or switch to a browser session with a warmer Instagram login state.', EXIT_CODES.TEMPFAIL);\n    }\n    if (result.errorCode === 'PRIVATE_OR_UNAVAILABLE') {\n        throw new CommandExecutionError(message, 'Open the post in a logged-in browser session and retry');\n    }\n    throw new CommandExecutionError(message);\n}\nasync function downloadInstagramMedia(items, outputDir) {\n    fs.mkdirSync(outputDir, { recursive: true });\n    for (const item of items) {\n        const destPath = path.join(outputDir, item.filename);\n        const result = await httpDownload(item.url, destPath, {\n            timeout: item.type === 'video' ? 120000 : 60000,\n        });\n        if (!result.success) {\n            throw new CommandExecutionError(`Failed to download ${item.filename}: ${result.error || 'unknown error'}`);\n        }\n        if (!Number.isFinite(result.size) || result.size <= 0) {\n            throw new CommandExecutionError(`Failed to verify downloaded bytes for ${item.filename}`);\n        }\n    }\n}","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/download.js#L302-L338","documentation":"When the in-page fetch reports errorCode 'PRIVATE_OR_UNAVAILABLE', handleFetchFailure throws a CommandExecutionError with this remediation hint: the post is either private, deleted, or otherwise unreachable for the current session. Unlike AUTH_REQUIRED, the session is valid but the account lacks access to the content, so the suggested fix is to open the post in a logged-in browser session that follows the owner.","triggerScenarios":"The metadata fetch returned {ok:false, errorCode:'PRIVATE_OR_UNAVAILABLE'} — the target shortcode resolves to a private account post, a deleted/removed post, or content geo/blocked for the session's user.","commonSituations":"Downloading a post from a private account you don't follow; post deleted by the author; typo in the URL/shortcode; account suspended or post removed for policy violations.","solutions":["Log in with an account that follows the private account, then retry","Verify the post still exists by opening the URL in a normal browser","Check the URL/shortcode for typos","If the account changed username or the post moved, use the updated URL"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify the post is reachable with the current account before scripting downloads\nconst reachable = await browserPage.evaluate((shortcode) =>\n  !document.querySelector('meta[property=\"og:title\"]')?.content.includes('Page Not Found'), shortcode);\nif (!reachable) throw new Error('Post is private, deleted, or unavailable to this account');","typeGuard":null,"tryCatchPattern":"try {\n  await run(['instagram', 'download', url]);\n} catch (e) {\n  if (String(e.message).includes('Open the post in a logged-in browser session')) {\n    // switch to an account that follows the private account, or skip this URL\n  } else throw e;\n}","preventionTips":["Only script downloads for posts visible to the authenticated account","Follow private accounts beforehand with the automation account","Validate the shortcode/URL before running","Check the post still exists in a normal browser when errors repeat"],"tags":["instagram","permissions","private-content","content-unavailable"],"backgroundTag":"content-unavailable-404","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}