Repository navigation
Name the fix in the unknown ecosystem error - #101
Open
abhinavgautam01 wants to merge 1 commit into
Open
abhinavgautam01 wants to merge 1 commit into
abhinavgautam01 wants to merge 1 commit into
Conversation
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.
Fixes #53
Problem
Each ecosystem registers itself from an
init()function. If a program importsgithub.com/git-pkgs/registrieswithoutgithub.com/git-pkgs/registries/all(or the specific ecosystem package), no ecosystems get registered. Then calls likeFetchPackageFromPURL(ctx, "pkg:pypi/flask", c)fail with:That message reads as if pypi is unsupported, when really an import is missing. It's even more confusing when some other dependency happens to register one ecosystem (say npm) but not the rest, because the failure then looks specific to one ecosystem.
Change
When an ecosystem isn't found,
core.Newnow reports how many ecosystems are registered and names the import that registers them:The count separates the two cases:
0 registeredmeans nothing was imported, while a nonzero count means the ecosystem really isn't available. It's read under the same read lock as the factory lookup, so the two values stay consistent.registries.New,FetchPackageFromPURLand the other PURL helpers all go throughcore.New, so every one of them gets the new message.Tests
internal/core/registry_test.go, which checks that the error includes the quoted ecosystem name, the registered count and the import hint.go test -race ./...,go vet ./...andgolangci-lint run ./...pass locally.GOOS=jsandGOOS=wasip1wasm builds pass, as do thetinygo-tagged tests.