{"record":{"id":"a0e5efc22b665760","repo":"jackwener/OpenCLI","slug":"wikidata-entity-wikidata-entity-qid-returned-n","errorCode":null,"errorMessage":"wikidata entity: Wikidata entity ${qid} returned no payload.","messagePattern":"wikidata entity: Wikidata entity (.+?) returned no payload\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/wikidata/entity.js","lineNumber":42,"sourceCode":"        'qid',\n        'type',\n        'label',\n        'description',\n        'aliases',\n        'claimPropertyCount',\n        'sitelinkCount',\n        'enwikiTitle',\n        'modified',\n        'url',\n    ],\n    func: async (args) => {\n        const qid = requireEntityId(args.id);\n        const language = requireLanguage(args.language);\n        const url = `${WIKIDATA_BASE}/wiki/Special:EntityData/${encodeURIComponent(qid)}.json`;\n        const body = await wikidataFetch(url, 'wikidata entity');\n        const entity = body?.entities?.[qid];\n        if (!entity) {\n            throw new EmptyResultError('wikidata entity', `Wikidata entity ${qid} returned no payload.`);\n        }\n        const claims = entity.claims && typeof entity.claims === 'object' ? entity.claims : {};\n        const sitelinks = entity.sitelinks && typeof entity.sitelinks === 'object' ? entity.sitelinks : {};\n        const enwiki = sitelinks?.enwiki?.title;\n        return [{\n            qid,\n            type: typeof entity.type === 'string' ? entity.type : null,\n            label: pickLocalised(entity.labels, language),\n            description: pickLocalised(entity.descriptions, language),\n            aliases: joinAliases(entity.aliases, language),\n            claimPropertyCount: Object.keys(claims).length,\n            sitelinkCount: Object.keys(sitelinks).length,\n            enwikiTitle: typeof enwiki === 'string' && enwiki.trim() ? enwiki : null,\n            modified: typeof entity.modified === 'string' ? entity.modified : null,\n            url: `${WIKIDATA_BASE}/wiki/${qid}`,\n        }];\n    },\n});","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikidata/entity.js#L24-L60","documentation":"The wikidata entity command fetches Special:EntityData/<qid>.json and expects body.entities[qid] to exist. If Wikidata responds successfully but the payload has no entry for the requested QID, the adapter raises an EmptyResultError with this message. It signals 'the request was valid but Wikidata returned nothing for this entity' rather than a network or argument failure.","triggerScenarios":"Calling `wikidata entity <qid>` where the response body.entities lacks the requested qid key — e.g. a deleted/redirected entity, or a malformed response despite HTTP 200.","commonSituations":"Querying a QID that has been deleted or merged into another entity on Wikidata; a typo in the ID that still matches the Q\\d+ pattern (e.g. an unused Q number); Wikidata returning an empty entities object during partial outages.","solutions":["Verify the entity exists by opening https://www.wikidata.org/wiki/<qid> in a browser — if it redirects, use the target QID","Re-run `wikidata search` to find the correct current QID","If the entity was merged, re-run against the merged-in QID","Retry later if Wikidata is having a partial outage"],"exampleFix":"// before\nconst [entity] = await runCli(['wikidata', 'entity', 'Q999999999']);\n// after\nconst [search] = await runCli(['wikidata', 'search', 'Douglas Adams']);\nconst [entity] = await runCli(['wikidata', 'entity', search.qid]);","handlingStrategy":"try-catch","validationCode":"// verify the QID resolves before use\nconst res = await fetch(`https://www.wikidata.org/wiki/Special:EntityData/${qid}.json`);\nif (res.ok && !Object.keys((await res.json())?.entities ?? {}).length) console.warn('no payload for', qid);","typeGuard":"function hasEntityPayload(body, qid) { return Boolean(body?.entities?.[qid]); }","tryCatchPattern":"try {\n    const [entity] = await runCli(['wikidata', 'entity', qid]);\n} catch (e) {\n    if (/returned no payload/.test(e.message)) {\n        // fall back to a search to find the current/merged QID\n    } else throw e;\n}","preventionTips":["Resolve merged/deleted entities via search before fetching","Validate QIDs against wikidata.org in your pipeline","Cache known-good QIDs and refresh on empty payloads","Prefer search-first flows over hardcoded QIDs"],"tags":["empty-result","remote-api","wikidata"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}