usestrix/strix · error · ValueError

Missing Postman collection id in '{target}' (expected postma

Error message

Missing Postman collection id in '{target}' (expected postman://<collection-uid>)

What it means

Raised when a target uses the postman:// scheme but no collection uid follows it. Strix expects the form postman://<collection-uid> with an optional ?env=<environment-uid> query; urlparse yields an empty netloc+path for bare 'postman://' so the reconstructed collection_uid is empty.

Source

Thrown at strix/interface/utils.py:1129


def infer_target_type(target: str) -> tuple[str, dict[str, str]]:  # noqa: PLR0911
    if not target or not isinstance(target, str):
        raise ValueError("Target must be a non-empty string")

    target = target.strip()

    if target.startswith("git@"):
        return "repository", {"target_repo": target}

    if target.startswith("git://"):
        return "repository", {"target_repo": target}

    parsed = urlparse(target)
    if parsed.scheme == "postman":
        collection_uid = f"{parsed.netloc}{parsed.path}".strip("/")
        if not collection_uid:
            raise ValueError(
                f"Missing Postman collection id in '{target}' (expected postman://<collection-uid>)"
            )
        details = {
            "target_spec": target,
            "spec_format": "postman",
            "source": "postman_api",
            "collection_uid": collection_uid,
        }
        query = parse_qs(parsed.query)
        env_uid = (query.get("env") or query.get("environment") or [""])[0].strip()
        if env_uid:
            details["environment_uid"] = env_uid
        return "api_spec", details

    if parsed.scheme in ("http", "https"):
        if parsed.username or parsed.password:
            return "repository", {"target_repo": target}
        if parsed.path.rstrip("/").endswith(".git"):

View on GitHub (pinned to 8551339130)

Solutions

  1. Use the full form: postman://<collection-uid> (optionally postman://<collection-uid>?env=<environment-uid>).
  2. Copy the collection uid from Postman (Collection info) or the Postman API (GET /collections) and paste it directly.
  3. Ensure POSTMAN_API_KEY is also set, since the Postman source requires it to fetch the collection.

Example fix

# before
strix -n -t "postman://?env=12345-abcdef"

# after
strix -n -t "postman://12345-abcdef?env=67890-fedcba"
Defensive patterns

Strategy: validation

Validate before calling

import re

def parse_postman_target(target: str) -> tuple[str, str | None]:
    m = re.fullmatch(r"postman://([^/?#]+)(?:[?&](?:env|environment)=([^&#]+))?", target)
    if not m:
        raise ValueError("expected postman://<collection-uid>[?env=<environment-uid>]")
    return m.group(1), m.group(2)

col_uid, env_uid = parse_postman_target(target)  # raises before infer_target_type

Type guard

def is_wellformed_postman_uri(target: str) -> bool:
    return bool(re.fullmatch(r"postman://[^/?#]+(?:\?.*)?", target))

Try / catch

try:
    ttype, details = infer_target_type(target)
except ValueError as e:
    if "Missing Postman collection id" in str(e):
        raise SystemExit("Postman targets need a collection uid: postman://<uid>[?env=<env-uid>]") from e
    raise

Prevention

When it happens

Trigger: Calling infer_target_type('postman://') or 'postman:///'; a truncated or mistyped target like 'postman://' plus only an env query, e.g. 'postman://?env=123-abc'.

Common situations: Copy-pasting a Postman URL that got truncated; hand-building the postman:// URI from a template and forgetting to substitute the uid placeholder; URL-encoding mistakes that push the uid into the query string.

Related errors


AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15). Data as JSON: /api/errors/cb17ea7f4e391fa0. Report an issue: GitHub.