langchain-ai/deepagents · error · MarketplaceError

Invalid marketplace URL

Error message

Invalid marketplace URL

What it means

When a `https://` source is parsed, the URL is passed to `urlparse` (marketplace.py:168-174). If `urlparse` raises `ValueError` — typically because the URL contains characters it cannot handle, such as an invalid IPv6 literal in brackets or a port that is not numeric — the library wraps it in a `MarketplaceError` with this message. It is a defensive guard so malformed URLs fail with a domain-specific error instead of leaking `ValueError`.

Source

Thrown at libs/code/deepagents_code/plugins/marketplace.py:174

        msg = "Please enter a marketplace source"
        raise MarketplaceError(msg)

    ssh_match = _SSH_GIT_RE.match(value)
    if ssh_match:
        return RepositoryMarketplaceSource(
            source_type="git", value=ssh_match.group(1), ref=ssh_match.group(2)
        )

    if value.startswith("http://"):
        msg = "Remote marketplace sources must use https"
        raise MarketplaceError(msg)
    if value.startswith("https://"):
        url, _, ref = value.partition("#")
        try:
            parsed = urlparse(url)
        except ValueError as exc:
            msg = "Invalid marketplace URL"
            raise MarketplaceError(msg) from exc
        path = parsed.path
        if path.endswith(".git") or "/_git/" in path:
            return RepositoryMarketplaceSource(
                source_type="git", value=url, ref=ref or None
            )
        if parsed.hostname in {"github.com", "www.github.com"}:
            parts = [part for part in path.split("/") if part]
            if len(parts) == _GITHUB_REPO_PART_COUNT:
                repo_path = "/".join(parts)
                git_url = urlunparse(parsed._replace(path=f"/{repo_path}.git"))
                return RepositoryMarketplaceSource(
                    source_type="git", value=git_url, ref=ref or None
                )
            if len(parts) > _GITHUB_REPO_PART_COUNT:
                msg = "GitHub marketplace URLs must contain exactly owner/repo"
                raise MarketplaceError(msg)
        return UrlMarketplaceSource(source_type="url", value=url)

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Inspect the URL for invalid port numbers or malformed bracketed IPv6 hosts and fix them.
  2. Validate the URL with `urllib.parse.urlparse` in a quick REPL check to see the underlying `ValueError`.
  3. If the URL comes from an env var or template, print/expand it to confirm the interpolated value is a well-formed https URL.

Example fix

// before
source = "https://[::1/marketplace.json"  # malformed IPv6
// after
source = "https://[::1]/marketplace.json"
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse

def validate_https_url(raw: str) -> str:
    url = raw.partition("#")[0]
    if not url.startswith("https://"):
        raise ValueError("source must be an https URL")
    urlparse(url)  # raises ValueError on malformed URLs
    return raw

Type guard

from urllib.parse import urlparse

def is_parseable_https_url(value: str) -> bool:
    try:
        parsed = urlparse(value.partition("#")[0])
    except ValueError:
        return False
    return parsed.scheme == "https" and bool(parsed.hostname)

Try / catch

try:
    source = parse_marketplace_source(raw)
except MarketplaceError as exc:
    if "Invalid marketplace URL" in str(exc):
        log.warning("Malformed https URL: %r", raw)
        raise ValueError(f"Fix the URL (check ports/IPv6 brackets): {raw}") from exc
    raise

Prevention

When it happens

Trigger: `parse_marketplace_source('https://[::1/marketplace.json')` (unterminated bracketed IPv6), `https://example.com:port/x` (non-numeric port), or URLs containing control characters, called directly or through `add_marketplace_source` / `_plugin_repository_source`.

Common situations: Hand-edited config files with typos in bracketed IPv6 hosts; template variables that expand to malformed URLs (e.g. `https://{{host}}:port/`); pasting URLs with stray whitespace-control characters from documents.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/e0617b368a3c6443. Report an issue: GitHub.