[fix] Isolate registry/package failures during sync instead of crashing - #95
Merged
Conversation
Manager.sync() called addPackage() once per whole registry package list and once per registry fetch, both unprotected: a single unreachable/misconfigured registry, or a single malformed package version anywhere in any registry's response, threw and aborted the entire sync - including every other registry and package not yet processed. This is the remaining half of the "validation throws crash sync/scan" finding from an internal spec-compliance audit (the scan() side was already fixed separately). sync() now processes one package version at a time, catching and recording failures (both per-registry fetch failures and per-version validation failures) into a new syncErrors list (getSyncErrors()) instead of throwing, so the rest of the sync can continue. While testing this, found and fixed a related pre-existing bug in addPackage(): it registered a brand-new Package into the index before attempting to add its versions, so when addVersion() threw (now reachable/observable now that sync() catches it instead of crashing first), an empty, orphaned Package was left behind in the index for a package that was never actually added. addPackage() now only registers a newly-created package after its versions have been added successfully. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Manager.sync()calledaddPackage()once per whole registry package list and once per registry fetch, both unprotected: a single unreachable/misconfigured registry, or a single malformed package version anywhere in any registry's response, threw and aborted the entire sync — including every other registry and package not yet processed. This is the remaining half of the "validation throws crash sync/scan" finding from an internal spec-compliance audit (thescan()side was already fixed in [fix] Discover unsupported packages during scan instead of ignoring them #92).sync()now processes one package version at a time, catching and recording failures — both per-registry fetch failures and per-version validation failures — into a newsyncErrorslist (getSyncErrors()) instead of throwing, so the rest of the sync continues.specification.md's Sync logic to describe this.addPackage()while testing this: it registered a brand-newPackageinto the index before attempting to add its versions, so whenaddVersion()threw (now actually observable, sincesync()catches it instead of crashing first), an empty, orphanedPackagewas left behind in the index for a package that was never really added —getPackage()would return a defined-but-empty object instead ofundefined.addPackage()now only registers a newly-created package after its versions have been added successfully.Test plan
npm run checkpasses (format, lint, build, tests — 193/193)example.invalid, RFC 2606 reserved) doesn't abort syncing the other, reachable registry; a malformed package version (mocked registry response) is isolated and recorded ingetSyncErrors()without affecting a sibling valid package🤖 Generated with Claude Code