LykosAI/StabilityMatrix · warning · DataValidationException

Invalid URL format

Error message

Invalid URL format

What it means

In InstallExtensionManualAsync, after the non-empty check, the validator attempts Uri.TryCreate with UriKind.Absolute; if parsing fails it throws DataValidationException('Invalid URL format'). It ensures only well-formed absolute URLs are accepted for manual extension installation.

Solutions

  1. Include a valid scheme, e.g. 'https://github.com/user/repo'.
  2. Avoid SCP-style remotes (git@host:path); convert them to https URLs.
  3. Validate the URL in a browser or with Uri.TryCreate before submitting.

Example fix

// before
if (!Uri.TryCreate(text, UriKind.Absolute, out _)) throw new DataValidationException("Invalid URL format");
// after
if (!Uri.TryCreate(text?.Trim(), UriKind.Absolute, out var uri)
    || uri.Scheme is not ("http" or "https" or "git"))
    throw new DataValidationException("Invalid URL format");
Defensive patterns

Strategy: validation

Validate before calling

bool IsValidAbsoluteUrl(string? s) =>
    Uri.TryCreate(s?.Trim(), UriKind.Absolute, out var u) && u.Scheme is "http" or "https" or "git";

Type guard

bool TryGetUrl(string? s, out Uri uri) => Uri.TryCreate(s?.Trim(), UriKind.Absolute, out uri!) && uri.Scheme != "unknown";

Try / catch

try { await InstallExtensionManualAsync(); }
catch (DataValidationException ex) { ShowWarning(ex.Message); }

Prevention

When it happens

Trigger: Submitting text in the Manual Extension Install dialog that is non-empty but not a parseable absolute URI, e.g. 'github.com/foo/bar' (no scheme), 'htp://bad', or a bare git SSH string like 'git@github.com:foo/bar'.

Common situations: Omitting the https:// scheme when pasting a repo URL; pasting an SCP-style git remote; trailing typos from manual typing.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/6eff2b66467eced4. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageExtensionBrowserViewModel.cs:705

        foreach (var item in InstalledItemsSearchCollection.FilteredItems)
        {
            item.IsSelected = true;
        }
    }

    [RelayCommand]
    private async Task InstallExtensionManualAsync()
    {
        var textField = new TextBoxField
        {
            Label = "Extension URL",
            Validator = text =>
            {
                if (string.IsNullOrWhiteSpace(text))
                    throw new DataValidationException("URL is required");

                if (!Uri.TryCreate(text, UriKind.Absolute, out _))
                    throw new DataValidationException("Invalid URL format");
            },
        };
        var dialog = DialogHelper.CreateTextEntryDialog("Manual Extension Install", "", [textField]);

        if (await dialog.ShowAsync() != ContentDialogResult.Primary)
            return;

        var url = textField.Text.Trim();
        if (string.IsNullOrWhiteSpace(url))
            return;

        if (
            !Uri.TryCreate(url, UriKind.Absolute, out var uri)
            || !uri.Host.Equals("github.com", StringComparison.OrdinalIgnoreCase)
        )
        {
            notificationService.Show("Invalid URL", "Please provide a valid GitHub repository URL.");
            return;

View on GitHub (pinned to af93d6ef57)