{"record":{"id":"41236b8fc78df0e1","repo":"ComposioHQ/composio","slug":"platformfailure","errorCode":"PlatformFailure","errorMessage":"dlopen(${path}) failed","messagePattern":"dlopen\\((.+?)\\) failed","errorType":"exception","errorClass":"KeyringError","httpStatus":null,"severity":"critical","filePath":"ts/packages/cli-keyring/src/stores/macos-security-ffi.ts","lineNumber":86,"sourceCode":"// Low-level dlopen / dlsym (used to resolve `kSec*` / `kCF*` extern const\n// data symbols that `bun:ffi`'s normal dlopen surface doesn't expose).\n// -----------------------------------------------------------------------------\n\nconst LIBSYSTEM = '/usr/lib/libSystem.B.dylib';\nconst SECURITY_FRAMEWORK = '/System/Library/Frameworks/Security.framework/Security';\nconst CORE_FOUNDATION = '/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation';\n\nconst RTLD_NOW = 0x2;\n\nconst libSystem = dlopen(LIBSYSTEM, {\n  dlopen: { args: [FFIType.ptr, FFIType.i32], returns: FFIType.u64 },\n  dlsym: { args: [FFIType.u64, FFIType.ptr], returns: FFIType.u64 },\n});\n\nfunction dlopenRaw(path: string): bigint {\n  const handle = libSystem.symbols.dlopen(cstr(path), RTLD_NOW);\n  if (handle === 0n) {\n    throw new KeyringError({\n      kind: 'PlatformFailure',\n      cause: new Error(`dlopen(${path}) failed`),\n    });\n  }\n  return handle;\n}\n\n/**\n * Resolve an extern const CFTypeRef data symbol: `dlsym` returns the\n * address of the storage slot (i.e. a pointer-to-pointer); we\n * dereference one level via `read.ptr` to get the actual CFTypeRef\n * value stored there. The symbol is stable for the process lifetime,\n * so caching the resolved BigInt is safe.\n */\nfunction dlsymCFConstant(handle: bigint, name: string): bigint {\n  const addr = libSystem.symbols.dlsym(handle, cstr(name));\n  if (addr === 0n) {\n    throw new KeyringError({","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/cli-keyring/src/stores/macos-security-ffi.ts#L68-L104","documentation":"The macOS keyring FFI layer called dlopen on a system library path and got a NULL handle, meaning the dynamic library could not be loaded. KeyringError kind 'PlatformFailure' with cause 'dlopen(<path>) failed'.","triggerScenarios":"Loading libSystem/CoreFoundation via FFI on a system where the path is wrong, the library is blocked (sandbox/hardened runtime), or running on a non-macOS platform.","commonSituations":"Sandboxed processes, changed library paths after macOS updates, or accidentally executing the macOS store on Linux/Windows.","solutions":["Verify you are on macOS and the library path exists","Disable library validation restrictions or run outside the restricting sandbox","Use a platform-appropriate store for your OS"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { platform } from 'node:process';\nif (platform !== 'darwin') throw new Error('macOS-only store');","typeGuard":"const isDarwin = (): boolean => process.platform === 'darwin';","tryCatchPattern":"catch (e) { if (e instanceof KeyringError && e.kind === 'PlatformFailure') { /* fall back to file store */ } else throw e; }","preventionTips":["Select the keyring store by platform at startup","Avoid sandbox profiles that block dlopen of system libs"],"tags":["keyring","macos","ffi","native","typescript"],"backgroundTag":"dynamic-library-load-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}