continuedev/continue · error · Error

Unknown URI type: ${(identifier as any).uriType}

Error message

Unknown URI type: ${(identifier as any).uriType}

What it means

encodePackageIdentifier received a PackageIdentifier whose uriType is neither 'slug' nor 'file'. The function switches on uriType to decide encoding strategy and rejects anything unrecognized, typically indicating a malformed or incompletely constructed identifier object.

Source

Thrown at packages/config-yaml/src/interfaces/slugs.ts:94

export function packageIdentifierToDisplayName(id: PackageIdentifier): string {
  switch (id.uriType) {
    case "file":
      return id.fileUri;
    case "slug":
      return id.fullSlug.packageSlug;
  }
}

export function encodePackageIdentifier(identifier: PackageIdentifier): string {
  switch (identifier.uriType) {
    case "slug":
      return encodeFullSlug(identifier.fullSlug);
    case "file":
      // For file paths, just return the path directly without a prefix
      return identifier.fileUri;
    default:
      throw new Error(`Unknown URI type: ${(identifier as any).uriType}`);
  }
}

export function decodePackageIdentifier(identifier: string): PackageIdentifier {
  // Shorthand: if it starts with . or /, then it's a path
  if (identifier.startsWith(".") || identifier.startsWith("/")) {
    return {
      uriType: "file",
      fileUri: identifier,
    };
  }
  // Keep support for explicit file:// protocol
  else if (identifier.startsWith("file://")) {
    return {
      uriType: "file",
      fileUri: identifier.substring(7),
    };
  }

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Check the value of identifier.uriType at the call site and correct it to 'slug' or 'file'
  2. If constructing identifiers programmatically, use a helper/factory that sets uriType from a literal type
  3. Add a type guard before calling to narrow to known variants

Example fix

// before
encodePackageIdentifier({ uriType: 'file-uri', fileUri: '/tmp/x' } as any);
// after
encodePackageIdentifier({ uriType: 'file', fileUri: '/tmp/x' });
Defensive patterns

Strategy: type-guard

Type guard

function isPackageIdentifier(id: unknown): id is PackageIdentifier {
  const v = id as any;
  return (
    (v?.uriType === 'file' && typeof v?.fileUri === 'string') ||
    (v?.uriType === 'slug' && !!v?.fullSlug?.ownerSlug && !!v?.fullSlug?.packageSlug)
  );
}

Prevention

When it happens

Trigger: Calling encodePackageIdentifier({uriType: 'registry'} as any) or passing an object where uriType is missing/misspelled (e.g. 'Slug', 'file-uri').

Common situations: Constructing PackageIdentifier literals by hand, drift after a type rename in an upgrade, or data crossing a serialization boundary that drops the uriType field.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/d8c20183695c40fa. Report an issue: GitHub.