{"record":{"id":"2cf36d4483317572","repo":"decolua/9router","slug":"installed-pxpipe-package-does-not-export-transform","errorCode":null,"errorMessage":"installed pxpipe package does not export transformAnthropicMessages","messagePattern":"installed pxpipe package does not export transformAnthropicMessages","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/pxpipe/loader.js","lineNumber":31,"sourceCode":"export async function loadPxpipe() {\n  if (cached) return cached;\n  if (loadPromise) return loadPromise;\n  loadPromise = doLoad().finally(() => { loadPromise = null; });\n  return loadPromise;\n}\n\nasync function doLoad() {\n  const info = getInstallInfo();\n  if (!info.installed) {\n    const err = new Error(\"PXPIPE is not installed\");\n    err.code = \"NOT_INSTALLED\";\n    throw err;\n  }\n  // Cache-bust per version so Repair/upgrade takes effect without a server restart.\n  const url = `${pathToFileURL(libraryEntry()).href}?v=${encodeURIComponent(info.version || \"0\")}`;\n  const mod = await import(/* webpackIgnore: true */ url);\n  if (typeof mod.transformAnthropicMessages !== \"function\") {\n    throw new Error(\"installed pxpipe package does not export transformAnthropicMessages\");\n  }\n  cached = { module: mod, version: info.version, loadedAt: Date.now() };\n  return cached;\n}\n\nexport function unloadPxpipe() {\n  const wasLoaded = !!cached;\n  cached = null;\n  return wasLoaded;\n}\n\n// Transform function for the request pipeline; null when unavailable (fail-open).\n// autoLoad controls whether a cold cache triggers a load (first request warms it).\nexport async function getTransform({ autoLoad = true } = {}) {\n  try {\n    if (!cached && !autoLoad) return null;\n    const { module: mod } = await loadPxpipe();\n    return mod.transformAnthropicMessages;","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/lib/pxpipe/loader.js#L13-L49","documentation":"Thrown by doLoad when the installed pxpipe package was successfully imported via dynamic import but does not export a `transformAnthropicMessages` function. The loader validates the module's API surface immediately after import and refuses to cache/use a module that doesn't implement the expected transform contract, protecting the request pipeline from calling an undefined function.","triggerScenarios":"A different or older/newer version of the pxpipe package is installed whose entry point no longer exports transformAnthropicMessages; a stale/renamed export upstream; the cache-busting URL (?v=<version>) resolved to a wrong file; a corrupted install where the entry resolved to an unexpected module.","commonSituations":"Upgrading pxpipe and the library got out of sync (package renamed the export); an old cached install predating the current API; npm installed a placeholder/renamed package with the same name; semver drift between the app expecting the export and the @latest package fetched during install.","solutions":["Check the installed package's entry (libraryEntry()) and confirm transformAnthropicMessages is a named export in its package.json main/exports target.","Reinstall/upgrade pxpipe to the version this app expects (use the Repair action, which bumps the ?v= cache-bust and reloads), then restart the pipeline load.","Pin a known-good pxpipe version instead of @latest so upstream renames can't break the contract.","If you control both sides, re-add/rename the export: module.exports.transformAnthropicMessages = transform... (or export function transformAnthropicMessages).","Clear PXPIPE_DIR and reinstall cleanly to rule out a corrupted/partial install resolving to the wrong entry."],"exampleFix":"// before (pxpipe package entry)\nexport { transformAnthropicMessages as transform };\n// after: keep the contract export name\nexport function transformAnthropicMessages({ body, model }) { /* ... */ }","handlingStrategy":"type-guard","validationCode":"const mod = await import(pathToFileURL(libraryEntry()).href);\nif (typeof mod.transformAnthropicMessages !== \"function\") {\n  throw new Error(\"installed pxpipe package does not export transformAnthropicMessages\");\n}","typeGuard":"function exportsTransform(mod) {\n  return !!mod && typeof mod.transformAnthropicMessages === \"function\";\n}","tryCatchPattern":"try {\n  const { module: mod } = await loadPxpipe();\n  if (!exportsTransform(mod)) throw new Error(\"incompatible pxpipe build\");\n} catch (e) {\n  if (e.message.includes(\"does not export transformAnthropicMessages\")) {\n    await repairPxpipe(); // reinstall matching version, bump cache-bust\n  } else throw e;\n}","preventionTips":["Pin pxpipe to a compatible version range instead of @latest.","After any pxpipe upgrade, verify the entry point still exports transformAnthropicMessages (check package.json exports/main).","Keep the loader's post-import typeof check in place — it converts a confusing later TypeError into a clear contract error.","When bumping versions, force the ?v= cache-bust so a stale module isn't reused.","Add a startup smoke test that loads pxpipe and reports the missing export early."],"tags":["pxpipe","module-loader","api-contract","dynamic-import"],"backgroundTag":"missing-export","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}