{"record":{"id":"99c863747da76a32","repo":"ComposioHQ/composio","slug":"cfdictionarycreatemutable-returned-null","errorCode":null,"errorMessage":"CFDictionaryCreateMutable returned NULL","messagePattern":"CFDictionaryCreateMutable returned NULL","errorType":"exception","errorClass":"KeyringError","httpStatus":null,"severity":"error","filePath":"ts/packages/cli-keyring/src/stores/macos-security-ffi.ts","lineNumber":394,"sourceCode":"  }\n  // CFData storage is a real heap pointer (never tagged), so the\n  // BigInt value fits in JS safe integer range and we can hand it to\n  // toArrayBuffer via Number. Copy into JS-owned memory so we don't\n  // retain the CFData longer than necessary.\n  const view = new Uint8Array(toArrayBuffer(Number(bytePtr) as unknown as never, 0, length));\n  return new Uint8Array(view);\n}\n\n/** Build a mutable CFDictionary. */\nfunction cfMutableDict(pool: CFPool): bigint {\n  const dict = cf.symbols.CFDictionaryCreateMutable(\n    0n,\n    0n,\n    K.kCFTypeDictionaryKeyCallBacks,\n    K.kCFTypeDictionaryValueCallBacks\n  );\n  if (dict === 0n) {\n    throw new KeyringError({\n      kind: 'PlatformFailure',\n      cause: new Error('CFDictionaryCreateMutable returned NULL'),\n    });\n  }\n  return pool.retain(dict);\n}\n\nfunction cfDictSet(dict: bigint, key: bigint, value: bigint): void {\n  cf.symbols.CFDictionaryAddValue(dict, key, value);\n}\n\n// -----------------------------------------------------------------------------\n// Store implementation\n// -----------------------------------------------------------------------------\n\nfunction validateSpecifier(service: string, user: string): void {\n  if (service.length === 0) {\n    throw new KeyringError({","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/cli-keyring/src/stores/macos-security-ffi.ts#L376-L412","documentation":"CFDictionaryCreateMutable returned NULL when allocating the mutable dictionary used to build a Security framework query. KeyringError kind 'PlatformFailure'.","triggerScenarios":"Any keyring query operation on macOS when CoreFoundation cannot allocate a new mutable dictionary — typically memory exhaustion.","commonSituations":"Long-running processes with leaks, containers with strict memory limits, or cascading failures after earlier FFI errors.","solutions":["Free leaked CF objects (ensure autorelease pools/release paths run) and retry","Raise memory limits or restart the process","Audit usage to ensure each operation's CF pool is drained"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof KeyringError && e.kind === 'PlatformFailure' && /CFDictionaryCreateMutable/.test(String(e.cause))) { return withRetry(fn, 1); } throw e; }","preventionTips":["Drain/release CF pools after each FFI operation","Set memory limits that accommodate the FFI layer"],"tags":["keyring","macos","ffi","native","memory","typescript"],"backgroundTag":"native-allocation-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}