{"record":{"id":"c06b0506f8050153","repo":"jackwener/OpenCLI","slug":"nuget-package-registration-leaf-pageurl-did-not","errorCode":null,"errorMessage":"nuget package registration leaf ${pageUrl} did not include an items array","messagePattern":"nuget package registration leaf (.+?) did not include an items array","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/nuget/package.js","lineNumber":55,"sourceCode":"        const body = await nugetFetch(url, 'nuget package');\n        const pages = Array.isArray(body?.items) ? body.items : [];\n        // Each page can be inline (with `items`) or a stub that needs another fetch\n        // for older packages. Inline is the common case for everything published in\n        // the last few years. We follow stub pages once each — at most ~5 round-trips.\n        const allEntries = [];\n        for (const [pageIndex, page] of pages.entries()) {\n            let pageItems = Array.isArray(page?.items) ? page.items : null;\n            if (!pageItems) {\n                // Stub page → fetch the leaf.\n                const pageUrl = typeof page?.['@id'] === 'string' ? page['@id'] : null;\n                if (!pageUrl) {\n                    throw new CommandExecutionError(\n                        `nuget package registration page ${pageIndex + 1} is missing @id for package \"${id}\"`,\n                    );\n                }\n                const leaf = await nugetFetch(pageUrl, 'nuget package page');\n                if (!Array.isArray(leaf?.items)) {\n                    throw new CommandExecutionError(\n                        `nuget package registration leaf ${pageUrl} did not include an items array`,\n                    );\n                }\n                pageItems = leaf.items;\n            }\n            for (const it of pageItems) {\n                if (!it || typeof it !== 'object' || !it.catalogEntry || typeof it.catalogEntry !== 'object') {\n                    throw new CommandExecutionError(\n                        `nuget package registration page ${pageIndex + 1} contains a malformed version entry`,\n                    );\n                }\n                allEntries.push(it);\n            }\n        }\n        if (!allEntries.length) {\n            throw new EmptyResultError('nuget package', `No published versions found for NuGet package \"${id}\".`);\n        }\n        // Sort by published desc; ties broken by version string descending.","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/nuget/package.js#L37-L73","documentation":"This error is thrown when the NuGet registration API returns a 'page' document whose nested items property is missing or not an array. The CLI expects each registration page to contain an items array of version entries; if the response shape deviates, the CLI cannot enumerate versions and aborts with a CommandExecutionError.","triggerScenarios":"Calling the nuget package command for a package id whose registration leaf page (fetched via nugetFetch(pageUrl, 'nuget package page')) returns JSON without an items array — e.g. a 200 response with an error body, a compressed/empty payload, a proxy or captive portal returning HTML, or a NuGet server/protocol change that renames or drops items.","commonSituations":"Corporate proxies or firewalls injecting HTML error pages; unofficial/private NuGet feeds (e.g. Azure Artifacts or a misconfigured source) returning a different registration schema; transient CDN glitches returning partial JSON; targeting a fake or malformed package id that resolves to an unexpected registration page.","solutions":["Retry the command — transient CDN/proxy glitches often resolve on a second attempt.","Verify the package id is correct and exists on nuget.org by checking https://api.nuget.org/v3/registration5-gz-semver2/<id>/index.json directly.","Check network path: bypass corporate proxies/VPNs or whitelist api.nuget.org.","If using a custom feed, confirm it implements the NuGet Server API v3 registration schema (items array on pages).","Update the CLI in case the NuGet registration format changed and a fix was released."],"exampleFix":"// before\nconst leaf = await nugetFetch(pageUrl, 'nuget package page');\nif (!Array.isArray(leaf?.items)) {\n    throw new CommandExecutionError(`nuget package registration leaf ${pageUrl} did not include an items array`);\n}\n// after\nconst leaf = await nugetFetch(pageUrl, 'nuget package page');\nif (!Array.isArray(leaf?.items)) {\n    // fall back to the raw (non-gzipped) registration endpoint before failing\n    const raw = await nugetFetch(pageUrl.replace('registration5-gz-semver2', 'registration5-semver1'), 'nuget package page');\n    if (!Array.isArray(raw?.items)) {\n        throw new CommandExecutionError(`nuget package registration leaf ${pageUrl} did not include an items array`);\n    }\n    leaf.items = raw.items;\n}","handlingStrategy":"type-guard","validationCode":"const res = await fetch(`https://api.nuget.org/v3/registration5-gz-semver2/${id.toLowerCase()}/index.json`);\nconst body = await res.json();\nconst ok = Array.isArray(body?.items) && body.items.every(p => Array.isArray(p?.items));\nif (!ok) throw new Error('Unexpected registration shape for ' + id);","typeGuard":"function hasItemsArray(page) {\n  return typeof page === 'object' && page !== null && Array.isArray(page.items);\n}","tryCatchPattern":"try {\n  const pkg = await nugetPackage(id);\n} catch (err) {\n  if (String(err.message).includes('did not include an items array')) {\n    // retry once, then report feed/network issue\n  } else throw err;\n}","preventionTips":["Verify package ids against search results before querying registration.","Whitelist api.nuget.org in proxies/firewalls to avoid injected HTML responses.","Pin to official NuGet v3 endpoints rather than unofficial mirrors.","Retry transient failures with backoff before surfacing the error."],"tags":["nuget","api-schema","network","validation"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}