{"record":{"id":"a255a152e88b03f7","repo":"usebruno/bruno","slug":"failed-to-create-client","errorCode":null,"errorMessage":"Failed to create client","messagePattern":"Failed to create client","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/grpc/grpc-client.js","lineNumber":666,"sourceCode":"    // Extract user-agent from headers if provided (case-insensitive)\n    // Set it as grpc.primary_user_agent channel option to prepend to the default user-agent\n    const userAgentKey = Object.keys(request.headers).find(\n      (key) => key.toLowerCase() === 'user-agent'\n    );\n    const userAgentValue = userAgentKey ? request.headers[userAgentKey] : null;\n\n    // Resolve proxy target and channel options\n    const { targetHost, proxyChannelOptions } = this.#resolveProxyTarget(host, proxyConfig);\n\n    const mergedChannelOptions = { ...channelOptions, ...proxyChannelOptions };\n    if (userAgentValue && !channelOptions?.['grpc.primary_user_agent']) {\n      mergedChannelOptions['grpc.primary_user_agent'] = userAgentValue;\n    }\n\n    const Client = makeGenericClientConstructor({});\n    const client = new Client(targetHost, credentials, mergedChannelOptions);\n    if (!client) {\n      throw new Error('Failed to create client');\n    }\n\n    let messages = request.body.grpc;\n    try {\n      messages = messages.map(({ content }) => safeJsonParse(content, 'message content'));\n    } catch (parseError) {\n      console.error('Failed to parse gRPC message content:', parseError);\n      client.close();\n      this.eventCallback('grpc:error', request.uid, collection.uid, {\n        error: parseError\n      });\n      return; // Exit early to prevent sending invalid data\n    }\n\n    const requestPath = path + methodPath;\n    const requestId = request.uid;\n    const collectionUid = collection.uid;\n    const metadata = new Metadata();","sourceCodeStart":648,"sourceCodeEnd":684,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/grpc/grpc-client.js#L648-L684","documentation":"Defensive guard after constructing a gRPC client via makeGenericClientConstructor({}). The constructor essentially always returns a client instance, so this branch is effectively dead code; if hit, it indicates the grpc-js factory returned null/undefined for an internal reason.","triggerScenarios":"makeGenericClientConstructor returned a falsy value when invoked with an empty service definition object, which under normal grpc-js operation does not occur.","commonSituations":"Practically unreachable. Theoretically a broken grpc-js build, a monkeypatched global, or a stubbed makeGenericClientConstructor in tests could trigger it.","solutions":["Treat as an internal invariant violation: reinstall node_modules and ensure @grpc/grpc-js is a supported version.","If seen in tests, check that makeGenericClientConstructor is not mocked to return undefined."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"const client = new Client(targetHost, credentials, mergedChannelOptions);\nif (!client || typeof client.makeUnaryRequest !== 'function') throw new Error('Failed to create client');","preventionTips":["Pin a known-good @grpc/grpc-js version.","Do not mock makeGenericClientConstructor to return falsy in tests."],"tags":["grpc","client-construction","invariant","unreachable"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}