{"record":{"id":"453f2d1941db3fef","repo":"janhq/jan","slug":"invalid-backend-archive-name-archivename","errorCode":null,"errorMessage":"Invalid backend archive name: ${archiveName}","messagePattern":"Invalid backend archive name: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/llamacpp-extension/src/index.ts","lineNumber":2873,"sourceCode":"      !(await fs.existsSync(path)) ||\n      (!path.endsWith('tar.gz') && !path.endsWith('zip'))\n    ) {\n      logger.error(`Invalid path or file ${path}`)\n      throw new Error(`Invalid path or file ${path}`)\n    }\n\n    const match = re.exec(archiveName)\n\n    if (!match) {\n      throw new Error(\n        `Failed to parse archive name: ${archiveName}. Expected format: [Optional prefix-]llama-<version>-bin-<backend>.(tar.gz|zip)`\n      )\n    }\n\n    const [, prefix, version, backend] = match\n\n    if (!version || !backend) {\n      throw new Error(`Invalid backend archive name: ${archiveName}`)\n    }\n\n    // Include prefix in the backend identifier if present\n    const backendIdentifier = prefix ? `${prefix}${backend}` : backend\n\n    logger.info(\n      `Detected prefix: ${prefix || 'none'}, version: ${version}, backend: ${backendIdentifier}`\n    )\n\n    const backendDir = await getBackendDir(backendIdentifier, version)\n\n    try {\n      await invoke('decompress', { path: path, outputDir: backendDir })\n    } catch (e) {\n      logger.error(`Failed to install: ${String(e)}`)\n      throw new Error(`Failed to decompress archive: ${String(e)}`)\n    }\n","sourceCodeStart":2855,"sourceCodeEnd":2891,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/extensions/llamacpp-extension/src/index.ts#L2855-L2891","documentation":"Defensive check after the archive-name regex has matched: the version and backend capture groups must both be non-empty. If the regex matched structurally but produced empty captures for version or backend (edge case in the regex), this error fires.","triggerScenarios":"An archive filename that technically satisfies the regex structure but has empty version or backend segments — this is rare given the regex requires non-empty patterns, but can occur with unexpected characters or a regex engine edge case.","commonSituations":"Extremely unusual filename constructions; regex was modified and introduced a bug allowing empty captures; an adversarial or corrupted filename.","solutions":["Rename the archive to follow the standard naming convention with explicit version and backend values.","If this fires on a correctly-named file, inspect the regex for a regression and verify the capture groups."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const BACKEND_ARCHIVE_RE = /^(.+?[-_])?llama(?:-main)?-(b\\d+(?:-[a-f0-9]+)?)(?:-cudart-llama)?-bin-(.+?)\\.(?:tar\\.gz|zip)$/\n\nfunction parseBackendArchive(name: string): { version: string; backend: string } | null {\n  const m = BACKEND_ARCHIVE_RE.exec(name)\n  if (!m || !m[2] || !m[3]) return null\n  return { version: m[2], backend: m[3] }\n}\n\n// Before install:\nconst parsed = parseBackendArchive(archiveName)\nif (!parsed) throw new Error('Cannot extract version and backend from archive name')","typeGuard":"function hasVersionAndBackend(match: RegExpMatchArray | null): match is RegExpMatchArray {\n  return !!match && !!match[2] && !!match[3]\n}","tryCatchPattern":null,"preventionTips":["Pre-validate the parsed version and backend from the archive name before invoking the install method.","Use the same regex in the UI file picker to filter acceptable archives."],"tags":["backend","validation","archive","naming-convention","typescript"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}