chocolatey/choco · error · ApplicationException
Source '{0}' is unable to be parsed
Error message
Source '{0}' is unable to be parsed What it means
Thrown by NugetCommon.GetRepositoryResources when a source string cannot be parsed as either an HTTP(S) URI or a local filesystem path. The code first checks if the source resolves to a valid URI (TrySourceAsUri is not null); if not, it attempts to convert to an absolute filesystem path via filesystem.GetFullPath. If the result is still not recognized as a local path (IsLocal is false), the source is considered unparseable.
Source
Thrown at src/chocolatey/infrastructure.app/nuget/NugetCommon.cs:260
// Conversion to absolute paths is handled by clients, not by the libraries as per
// https://github.com/NuGet/NuGet.Client/pull/3783
if (nugetSource.TrySourceAsUri is null)
{
string fullsource;
try
{
fullsource = filesystem.GetFullPath(source);
}
catch
{
// If an invalid source was passed in, we don't care here, pass it along
fullsource = source;
}
nugetSource = new PackageSource(fullsource);
if (!nugetSource.IsLocal)
{
throw new ApplicationException("Source '{0}' is unable to be parsed".FormatWith(source));
}
"chocolatey".Log().Debug("Updating Source path from {0} to {1}".FormatWith(source, fullsource));
updatedSources.AppendFormat("{0};", fullsource);
}
else
{
updatedSources.AppendFormat("{0};", source);
}
nugetSource.ClientCertificates = sourceClientCertificates;
var repo = Repository.Factory.GetCoreV3(nugetSource);
if (nugetSource.IsHttp || nugetSource.IsHttps)
{
#pragma warning disable RS0030 // Do not used banned APIs
var httpSourceResource = repo.GetResource<HttpSourceResource>();
#pragma warning restore RS0030 // Do not used banned APIs
View on GitHub (pinned to 0d5abdd10c)
Solutions
- Verify the source URL is a valid HTTP(S) URI: 'choco install pkg --source=https://valid.url/feed'
- Verify the local source path exists and is accessible: 'choco install pkg --source=C:\packages'
- Remove typos in the protocol (must be http:// or https://)
- Check for hidden characters, quotes, or whitespace in the source string
- If using environment variables in the path, ensure they resolve before passing
Example fix
// before choco install mypackage --source=htps://community.chocolatey.org/api/v2/ // after choco install mypackage --source=https://community.chocolatey.org/api/v2/
Defensive patterns
Strategy: validation
Validate before calling
// Validate source before passing to NugetCommon
bool IsValidSource(string source)
{
if (Uri.TryCreate(source, UriKind.Absolute, out var uri))
return uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps;
try
{
var full = Path.GetFullPath(source);
return Directory.Exists(full) || File.Exists(full);
}
catch { return false; }
}
if (!IsValidSource(configSource))
{
Console.Error.WriteLine($"Source '{configSource}' is not a valid HTTP(S) URL or local path.");
} Type guard
public static bool IsValidSourceUrl(string source)
{
if (string.IsNullOrWhiteSpace(source)) return false;
if (Uri.TryCreate(source, UriKind.Absolute, out var uri))
return uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps;
try { Path.GetFullPath(source); return true; }
catch { return false; }
} Try / catch
try
{
var repos = NugetCommon.GetRepositoryResources(config, logger, filesystem, cacheContext);
}
catch (ApplicationException ex) when (ex.Message.Contains("unable to be parsed"))
{
logger.Error($"Source could not be parsed. Verify it is a valid HTTP(S) URL or local path.");
} Prevention
- Verify source URLs start with http:// or https:// before using them
- For local paths, confirm the directory or file exists
- Remove extra whitespace, quotes, or control characters from source strings
- Expand environment variables in paths before passing them as sources
- Use 'choco source list' to verify configured sources are valid
When it happens
Trigger: Passing a malformed source URL (e.g. 'htp://feed.example.com' with a typo in the protocol). Passing a source that is neither a valid URI nor a valid filesystem path (e.g. 'feed:||broken'). Passing an empty or whitespace-only source after the initial empty-source filtering. Passing a UNC path or environment-variable-containing path that GetFullPath cannot resolve.
Common situations: Typo in the --source URL ('https' misspelled). Source string contains unresolved environment variables or ~ that aren't expanded. Configuration file has a corrupted source entry. Network proxy or redirect URL that doesn't parse as a standard URI. Source passed with extra quotes or whitespace characters.
Related errors
- You must specify 'source' to remove an API key.
- You must specify both 'source' and 'key' to set an API key.
- When using the '--source' option with the 'choco list' comma
- The default push source configuration is not set. Either pas
- An error has occurred. This package version already exists o
AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13).
Data as JSON: /api/errors/9bc48b9fe744b33a.
Report an issue: GitHub.