jackwener/OpenCLI · error · CommandExecutionError

nuget package registration page ${pageIndex + 1} contains a

Error message

nuget package registration page ${pageIndex + 1} contains a malformed version entry

What it means

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.

Source

Thrown at clis/nuget/package.js:63

            if (!pageItems) {
                // Stub page → fetch the leaf.
                const pageUrl = typeof page?.['@id'] === 'string' ? page['@id'] : null;
                if (!pageUrl) {
                    throw new CommandExecutionError(
                        `nuget package registration page ${pageIndex + 1} is missing @id for package "${id}"`,
                    );
                }
                const leaf = await nugetFetch(pageUrl, 'nuget package page');
                if (!Array.isArray(leaf?.items)) {
                    throw new CommandExecutionError(
                        `nuget package registration leaf ${pageUrl} did not include an items array`,
                    );
                }
                pageItems = leaf.items;
            }
            for (const it of pageItems) {
                if (!it || typeof it !== 'object' || !it.catalogEntry || typeof it.catalogEntry !== 'object') {
                    throw new CommandExecutionError(
                        `nuget package registration page ${pageIndex + 1} contains a malformed version entry`,
                    );
                }
                allEntries.push(it);
            }
        }
        if (!allEntries.length) {
            throw new EmptyResultError('nuget package', `No published versions found for NuGet package "${id}".`);
        }
        // Sort by published desc; ties broken by version string descending.
        const sorted = [...allEntries].sort((a, b) => {
            const ap = a?.catalogEntry?.published ?? '';
            const bp = b?.catalogEntry?.published ?? '';
            if (ap !== bp) return bp.localeCompare(ap);
            const av = a?.catalogEntry?.version ?? '';
            const bv = b?.catalogEntry?.version ?? '';
            return bv.localeCompare(av);
        });

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command to rule out a transient upstream catalog issue.
  2. Inspect the registration JSON for the package (https://api.nuget.org/v3/registration5-gz-semver2/<id>/index.json) to find the malformed entry.
  3. If the package is on a private mirror, sync/reindex the mirror or fall back to the official feed.
  4. Verify the package id is valid — some feeds emit malformed entries for unknown or deleted packages.
  5. Update the CLI or file a bug if the official feed persistently returns malformed entries.

Example fix

// before
for (const it of pageItems) {
    if (!it || typeof it !== 'object' || !it.catalogEntry || typeof it.catalogEntry !== 'object') {
        throw new CommandExecutionError(`nuget package registration page ${pageIndex + 1} contains a malformed version entry`);
    }
    allEntries.push(it);
}
// after
for (const it of pageItems) {
    if (!it || typeof it !== 'object' || !it.catalogEntry || typeof it.catalogEntry !== 'object') {
        console.warn(`skipping malformed version entry on page ${pageIndex + 1}`);
        continue; // skip instead of failing the whole package
    }
    allEntries.push(it);
}
Defensive patterns

Strategy: type-guard

Validate before calling

const idx = await (await fetch(regUrl)).json();
for (const page of idx.items ?? []) {
  for (const it of page.items ?? []) {
    if (!it?.catalogEntry || typeof it.catalogEntry !== 'object') throw new Error('malformed entry');
  }
}

Type guard

function isValidVersionEntry(it) {
  return !!it && typeof it === 'object' && !!it.catalogEntry && typeof it.catalogEntry === 'object';
}

Try / catch

try {
  const pkg = await nugetPackage(id);
} catch (err) {
  if (String(err.message).includes('malformed version entry')) {
    console.warn('Feed returned malformed registration data; retrying or switching feed');
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f97fe88c17081816. Report an issue: GitHub.