{"record":{"id":"a0a1fcd8869b878c","repo":"jackwener/OpenCLI","slug":"twitter-profile-response-for-screenname-is-mis","errorCode":null,"errorMessage":"Twitter profile response for @${screenName} is missing profile fields","messagePattern":"Twitter profile response for @(.+?) is missing profile fields","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/twitter/profile.js","lineNumber":48,"sourceCode":"    return typeof value === 'string' ? value : '';\n}\n\nfunction countField(...values) {\n    for (const value of values) {\n        if (typeof value === 'number' && Number.isFinite(value))\n            return value;\n    }\n    return 0;\n}\n\nexport function mapTwitterProfileResult(result, screenName) {\n    if (!isPlainObject(result)) {\n        throw new CommandExecutionError(`Twitter profile response for @${screenName} is malformed`);\n    }\n    const hasLegacy = isPlainObject(result.legacy);\n    const hasCore = isPlainObject(result.core);\n    if (!hasLegacy && !hasCore) {\n        throw new CommandExecutionError(`Twitter profile response for @${screenName} is missing profile fields`);\n    }\n    const legacy = hasLegacy ? result.legacy : {};\n    const core = hasCore ? result.core : {};\n    if (!stringField(core.screen_name) && !stringField(legacy.screen_name) && !stringField(core.name) && !stringField(legacy.name) && !stringField(core.created_at) && !stringField(legacy.created_at)) {\n        throw new CommandExecutionError(`Twitter profile response for @${screenName} is missing profile identity fields`);\n    }\n    const location = isPlainObject(result.location) ? result.location : {};\n    const expandedUrl = stringField(result.website?.url) || stringField(legacy.entities?.url?.urls?.[0]?.expanded_url);\n    return [{\n        screen_name: stringField(core.screen_name) || stringField(legacy.screen_name) || screenName,\n        name: stringField(core.name) || stringField(legacy.name),\n        bio: stringField(result.profile_bio?.description) || stringField(legacy.description),\n        location: stringField(location.location) || stringField(legacy.location),\n        url: stringField(expandedUrl),\n        followers: countField(result.relationship_counts?.followers, legacy.followers_count, legacy.normal_followers_count),\n        following: countField(result.relationship_counts?.following, legacy.friends_count),\n        tweets: countField(result.tweet_counts?.tweets, legacy.statuses_count),\n        likes: countField(result.action_counts?.favorites_count, legacy.favourites_count),","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/profile.js#L30-L66","documentation":"CommandExecutionError thrown by mapTwitterProfileResult when the response is an object but contains neither result.legacy nor result.core — the two containers X uses for profile data. This means X responded but the payload lacks the expected profile structure.","triggerScenarios":"The GraphQL UserByScreenName response parses to an object missing both legacy and core fields — typically an error/tombstone object ('User is unavailable', suspended account) or a changed API envelope.","commonSituations":"Viewing a suspended, deleted, or protected account; X A/B testing a new response envelope; API version drift after X ships changes; the profile exists but lookup was served an error sub-object.","solutions":["Confirm the account exists and is public by visiting the profile URL in the browser","Try a different handle to determine if it's account-specific or a systemic API change","Log in fresh — some payloads differ for degraded sessions","If all handles fail, X changed its response shape; update mapTwitterProfileResult or the fetch call"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function looksLikeProfilePayload(res) {\n  return res != null && typeof res === 'object' &&\n    ('legacy' in res || 'core' in res);\n}\n// run on the raw response before mapping, when accessible","typeGuard":"const hasProfileContainers = (r) =>\n  r != null && typeof r === 'object' && !Array.isArray(r) &&\n  (isPlainObject(r.legacy) || isPlainObject(r.core));","tryCatchPattern":"try {\n  const profile = await opencli('twitter profile', { username });\n} catch (e) {\n  if (e.name === 'CommandExecutionError' && /missing profile fields/.test(e.message)) {\n    // account may be suspended/deleted or X changed the envelope\n    console.warn('No profile data for', username, '- check account status');\n  } else throw e;\n}","preventionTips":["Check the account exists and is not suspended before lookup","Treat this as account-specific first, then API-change","Keep the library updated for X API envelope changes","Retry once with a fresh session before giving up"],"tags":["twitter","api-response","schema"],"backgroundTag":"api-response-schema-mismatch","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}