{"record":{"id":"83fc207ca44133f7","repo":"ComposioHQ/composio","slug":"cfstringcreatewithbytes-returned-null","errorCode":null,"errorMessage":"CFStringCreateWithBytes returned NULL","messagePattern":"CFStringCreateWithBytes returned NULL","errorType":"exception","errorClass":"KeyringError","httpStatus":null,"severity":"error","filePath":"ts/packages/cli-keyring/src/stores/macos-security-ffi.ts","lineNumber":344,"sourceCode":"    for (let i = this.refs.length - 1; i >= 0; i--) {\n      cf.symbols.CFRelease(this.refs[i]!);\n    }\n    this.refs.length = 0;\n  }\n}\n\n/** Create a CFString from a JS string (UTF-8 bytes). Throws on allocation failure. */\nfunction cfStringFromJs(pool: CFPool, s: string): bigint {\n  const bytes = textEncoder.encode(s);\n  const ref = cf.symbols.CFStringCreateWithBytes(\n    0n, // kCFAllocatorDefault\n    bytes,\n    BigInt(bytes.byteLength),\n    kCFStringEncodingUTF8,\n    false\n  );\n  if (ref === 0n) {\n    throw new KeyringError({\n      kind: 'PlatformFailure',\n      cause: new Error('CFStringCreateWithBytes returned NULL'),\n    });\n  }\n  return pool.retain(ref);\n}\n\n/** Read a CFString into a JS UTF-8 string. Only used for error messages. */\nfunction cfStringToJs(cfString: bigint): string {\n  const buf = new Uint8Array(4096);\n  const ok = cf.symbols.CFStringGetCString(\n    cfString,\n    buf,\n    BigInt(buf.byteLength),\n    kCFStringEncodingUTF8\n  );\n  if (!ok) return '<unrepresentable>';\n  const end = buf.indexOf(0);","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/cli-keyring/src/stores/macos-security-ffi.ts#L326-L362","documentation":"CFStringCreateWithBytes returned NULL when converting a JS string to a CFString for a Security framework query. KeyringError kind 'PlatformFailure'.","triggerScenarios":"Calling getSecret/deleteCredential (which build attribute dictionaries) when CoreFoundation cannot allocate the string — invalid encoding input or memory pressure.","commonSituations":"Extreme memory pressure, or malformed byte input to the FFI layer; rare platform-level allocation failures.","solutions":["Retry the operation (transient allocation failures can succeed on retry)","Reduce memory pressure / check for leaks in long-running processes","Update the FFI layer if reproducible and report upstream"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof KeyringError && e.kind === 'PlatformFailure' && /CFStringCreateWithBytes/.test(String(e.cause))) { await sleep(100); return retry(fn, 2); } throw e; }","preventionTips":["Monitor process memory in long-running daemons"],"tags":["keyring","macos","ffi","native","typescript"],"backgroundTag":"native-api-returned-null","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}