{"record":{"id":"f97fe88c17081816","repo":"jackwener/OpenCLI","slug":"nuget-package-registration-page-pageindex-1-c","errorCode":null,"errorMessage":"nuget package registration page ${pageIndex + 1} contains a malformed version entry","messagePattern":"nuget package registration page (.+?) contains a malformed version entry","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/nuget/package.js","lineNumber":63,"sourceCode":"            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.\n        const sorted = [...allEntries].sort((a, b) => {\n            const ap = a?.catalogEntry?.published ?? '';\n            const bp = b?.catalogEntry?.published ?? '';\n            if (ap !== bp) return bp.localeCompare(ap);\n            const av = a?.catalogEntry?.version ?? '';\n            const bv = b?.catalogEntry?.version ?? '';\n            return bv.localeCompare(av);\n        });","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/nuget/package.js#L45-L81","documentation":"Thrown when an entry inside a NuGet registration page's items array is not an object or lacks a valid catalogEntry object. The CLI relies on catalogEntry (version, published) to sort and list versions, so malformed entries make the page data unusable and a CommandExecutionError is raised.","triggerScenarios":"Iterating pageItems from a registration page where an element is null, a non-object (e.g. a string/number), or an object without it.catalogEntry being an object — typically from a non-conformant feed, a partially written catalog, or an intermediary corrupting the JSON.","commonSituations":"Third-party or private NuGet mirrors returning degraded registration data; upstream NuGet catalog maintenance producing entries with missing catalogEntry; custom search/proxy layers rewriting responses; buggy server implementations of the v3 registration resource.","solutions":["Retry the command to rule out a transient upstream catalog issue.","Inspect the registration JSON for the package (https://api.nuget.org/v3/registration5-gz-semver2/<id>/index.json) to find the malformed entry.","If the package is on a private mirror, sync/reindex the mirror or fall back to the official feed.","Verify the package id is valid — some feeds emit malformed entries for unknown or deleted packages.","Update the CLI or file a bug if the official feed persistently returns malformed entries."],"exampleFix":"// before\nfor (const it of pageItems) {\n    if (!it || typeof it !== 'object' || !it.catalogEntry || typeof it.catalogEntry !== 'object') {\n        throw new CommandExecutionError(`nuget package registration page ${pageIndex + 1} contains a malformed version entry`);\n    }\n    allEntries.push(it);\n}\n// after\nfor (const it of pageItems) {\n    if (!it || typeof it !== 'object' || !it.catalogEntry || typeof it.catalogEntry !== 'object') {\n        console.warn(`skipping malformed version entry on page ${pageIndex + 1}`);\n        continue; // skip instead of failing the whole package\n    }\n    allEntries.push(it);\n}","handlingStrategy":"type-guard","validationCode":"const idx = await (await fetch(regUrl)).json();\nfor (const page of idx.items ?? []) {\n  for (const it of page.items ?? []) {\n    if (!it?.catalogEntry || typeof it.catalogEntry !== 'object') throw new Error('malformed entry');\n  }\n}","typeGuard":"function isValidVersionEntry(it) {\n  return !!it && typeof it === 'object' && !!it.catalogEntry && typeof it.catalogEntry === 'object';\n}","tryCatchPattern":"try {\n  const pkg = await nugetPackage(id);\n} catch (err) {\n  if (String(err.message).includes('malformed version entry')) {\n    console.warn('Feed returned malformed registration data; retrying or switching feed');\n  } else throw err;\n}","preventionTips":["Prefer the official nuget.org feed over third-party mirrors.","Re-sync private mirrors that serve degraded registration data.","Inspect registration JSON directly when a specific package repeatedly fails.","Keep the CLI updated for schema-tolerance fixes."],"tags":["nuget","api-schema","data-corruption","validation"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}