typescript-utcp icon indicating copy to clipboard operation
typescript-utcp copied to clipboard

`UtcpVariableNotFoundError` is thrown but not exported from `@utcp/sdk`

Open trackoor opened this issue 3 weeks ago • 0 comments

UtcpClient and DefaultVariableSubstitutor throw UtcpVariableNotFoundError when a referenced variable is missing, and the @utcp/sdk README ("Error Handling", packages/core/README.md) shows import { UtcpVariableNotFoundError } from '@utcp/sdk', but @utcp/sdk does not export UtcpVariableNotFoundError from its entry point or .d.ts types (and package.json exports only exposes ".").

Reproduction

Save as repro.mjs:

import * as sdk from "@utcp/sdk";

console.log("exported:", "UtcpVariableNotFoundError" in sdk);

const client = await sdk.UtcpClient.create(process.cwd(), {});
try {
  await client.registerManual({
    name: "api",
    call_template_type: "text",
    content: "${MISSING}",
  });
} catch (err) {
  console.log("thrown:", err.name, err.variableName);
}
await client.close();

Run:

npm init -y && npm install @utcp/[email protected]
node repro.mjs
node --input-type=module -e 'import { UtcpVariableNotFoundError } from "@utcp/sdk";'

Actual output

node repro.mjs:

exported: false
thrown: UtcpVariableNotFoundError api_MISSING
UTCP Client closed, with the protocols it owned.

Named import from the README:

SyntaxError: The requested module '@utcp/sdk' does not provide an export named 'UtcpVariableNotFoundError'

TypeScript (tsc --noEmit) also fails with:

error TS2305: Module '"@utcp/sdk"' has no exported member 'UtcpVariableNotFoundError'.

Expected behavior

UtcpVariableNotFoundError is re-exported from packages/core/src/index.ts (export * from './exceptions/utcp_variable_not_found_error';) so callers can import it from @utcp/sdk and check error instanceof UtcpVariableNotFoundError as documented.

Versions

  • @utcp/sdk: 1.2.0 (latest on npm) and main (ea4902d)
  • Node.js: v26.13.0 (Linux x64)

Credit: https://ucsbplse.github.io/

trackoor avatar Nov 15 '26 17:11 trackoor