{"record":{"id":"36d4ee81782b2424","repo":"unionlabs/union","slug":"invalid-aptos-transport","errorCode":null,"errorMessage":"Invalid Aptos transport","messagePattern":"Invalid Aptos transport","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"typescript-sdk/src/aptos/client.ts","lineNumber":56,"sourceCode":" * Overloads for retrieving an Aptos client.\n */\nasync function getAptosClient(\n  parameters: AptosClientParameters & { authAccess: \"key\" },\n): Promise<{ authAccess: \"key\"; aptos: Aptos; signer: AptosAccount }>\n\n// async function getAptosClient(\n//   parameters: AptosClientParameters & { authAccess: \"wallet\" }\n// ): Promise<{ authAccess: \"wallet\"; aptos: Aptos; signer: AptosBrowserWallet }>\n\nasync function getAptosClient(\n  parameters: AptosClientParameters & { authAccess: AuthAccess },\n): Promise<\n  | { authAccess: \"key\"; aptos: Aptos; signer: AptosAccount }\n  | { authAccess: \"wallet\"; aptos: Aptos; signer: AptosBrowserWallet }\n> {\n  if (parameters.authAccess === \"key\") {\n    if (typeof parameters.transport !== \"function\") {\n      throw new Error(\"Invalid Aptos transport\")\n    }\n    const rpcUrl = parameters.transport({}).value?.url\n    if (!rpcUrl) {\n      throw new Error(\"No Aptos RPC URL found\")\n    }\n    const config = new AptosConfig({\n      fullnode: rpcUrl,\n      network: Network.CUSTOM,\n    })\n    return {\n      authAccess: \"key\",\n      aptos: new Aptos(config),\n      signer: parameters.account as AptosAccount,\n    }\n  }\n\n  if (parameters.authAccess === \"wallet\") {\n    if (typeof parameters.transport !== \"object\") {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/unionlabs/union/blob/031785bb6dc6b957c624e62bc64c184409c97d7b/typescript-sdk/src/aptos/client.ts#L38-L74","documentation":"getAptosClient with authAccess \"key\" requires parameters.transport to be a viem-style transport function: it is invoked as transport({}) and the client reads .value?.url for the RPC endpoint. Anything that is not a function — a raw URL string, a plain object, undefined — fails the typeof check and throws 'Invalid Aptos transport'. A parallel check then requires transport({}).value?.url to be non-empty.","triggerScenarios":"Calling createUnionClient with a string RPC URL instead of http(url); passing a config object as transport; a custom/test-double transport whose return value has no .value.url; omitting transport entirely.","commonSituations":"Habit of passing URLs directly (common with raw fetch or other SDKs); custom transports built for mocking in tests that don't follow the viem Transport shape.","solutions":["Wrap the URL in a transport: import { http } from \"viem\" and pass transport: http(\"https://fullnode.testnet.aptoslabs.com/v1\")","For custom transports, make them return { value: { url } } so the client can extract the endpoint","Confirm authAccess: \"key\" is intended — the wallet flow does not hit this check"],"exampleFix":"// before\nconst client = createUnionClient({\n  chainId: union.testnet.cosmosChainId,\n  transport: \"https://fullnode.testnet.aptoslabs.com/v1\", // string!\n})\n\n// after\nimport { http } from \"viem\"\n\nconst client = createUnionClient({\n  chainId: union.testnet.cosmosChainId,\n  transport: http(\"https://fullnode.testnet.aptoslabs.com/v1\"),\n})","handlingStrategy":"type-guard","validationCode":"if (typeof parameters.transport !== \"function\") {\n  throw new Error(\"transport must be a Transport function, e.g. http(rpcUrl)\")\n}","typeGuard":"import type { Transport } from \"viem\"\n\nconst isTransport = (t: unknown): t is Transport => typeof t === \"function\"","tryCatchPattern":"try {\n  const client = await getAptosClient({ authAccess: \"key\", transport })\n} catch (e) {\n  if (e instanceof Error && e.message === \"Invalid Aptos transport\") {\n    throw new Error(\"Pass a viem Transport: http('https://…/v1'), not a URL string\")\n  }\n  throw e\n}","preventionTips":["Always wrap RPC URLs with viem's http() before passing them as transport","For custom transports, return { value: { url } } so the client can extract the endpoint","Type the client options as Transport at the call boundary to catch strings at compile time"],"tags":["aptos","transport","viem","validation"],"backgroundTag":null,"analyzedSha":"031785bb6dc6b957c624e62bc64c184409c97d7b","analyzedAt":"2026-08-16T06:24:09.996Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}