{"record":{"id":"57e8d62b402aff96","repo":"usebruno/bruno","slug":"unsupported-method-type-methodtype","errorCode":null,"errorMessage":"Unsupported method type: ${methodType}","messagePattern":"Unsupported method type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/grpc/grpc-client.js","lineNumber":494,"sourceCode":"   * @param {Object} options.metadata - The metadata object\n   */\n  #handleConnection(options) {\n    const methodType = this.#getMethodType(options.method);\n    switch (methodType) {\n      case 'unary':\n        this.#handleUnaryResponse(options);\n        break;\n      case 'client-streaming':\n        this.#handleClientStreamingResponse(options);\n        break;\n      case 'server-streaming':\n        this.#handleServerStreamingResponse(options);\n        break;\n      case 'bidi-streaming':\n        this.#handleBidiStreamingResponse(options);\n        break;\n      default:\n        throw new Error(`Unsupported method type: ${methodType}`);\n    }\n  }\n\n  /**\n   * Handle unary responses\n   */\n  #handleUnaryResponse({ client, requestId, requestPath, method, messages, metadata, collectionUid }) {\n    const rpc = client.makeUnaryRequest(\n      requestPath,\n      method.requestSerialize,\n      method.responseDeserialize,\n      messages[0],\n      metadata,\n      (error, res) => {\n        this.eventCallback('grpc:response', requestId, collectionUid, { error, res });\n      }\n    );\n    this.#addConnection(requestId, { rpc, client });","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/grpc/grpc-client.js#L476-L512","documentation":"Thrown by GrpcClient.#handleConnection when the resolved gRPC method type does not match one of the four supported RPC patterns (unary, client-streaming, server-streaming, bidi-streaming). The type is derived by #getMethodType from the method definition's requestStream/responseStream boolean flags, so an undefined or malformed method object reaches the default branch.","triggerScenarios":"A gRPC request is dispatched where options.method lacks requestStream/responseStream, or both are non-boolean (e.g. the method definition loaded from local storage lost its functions during serialization, or reflection returned a stub method without stream flags).","commonSituations":"Stale method metadata cached in local storage after a proto change; a corrupt reflection response; calling a request whose proto was swapped but the method path was not re-resolved; downgrade of grpc-js where ServiceType shape changed.","solutions":["Force-refresh the service definition (re-run server reflection / re-import the proto) so #getMethodType receives a well-formed method with requestStream and responseStream.","Verify request.method points to a valid '/Service/Method' path that exists in the loaded proto, then retry.","Clear cached gRPC metadata from local storage and re-open the collection so methods are re-parsed from the proto file.","Upgrade @grpc/grpc-js and bruno-requests to matching versions if the ServiceType object shape differs across releases."],"exampleFix":"// before: method came from stale local-storage cache (lost requestSerialize + stream flags)\nconst method = cachedMethod; // { path: '/Foo/Bar' }  -> throws\n\n// after: re-resolve from a fresh proto load / reflection so flags are present\nconst method = await client.#getMethodFromPath('/Foo/Bar');\n// method now has requestStream:false, responseStream:false, requestSerialize, responseDeserialize","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set(['unary','client-streaming','server-streaming','bidi-streaming']);\nfunction assertMethodType(method) {\n  const has = typeof method?.requestStream === 'boolean' && typeof method?.responseStream === 'boolean';\n  if (!has) throw new Error('method is missing requestStream/responseStream booleans');\n  const t = String(method.requestStream) + String(method.responseStream);\n  const type = t==='falsefalse'?'unary':t==='truefalse'?'client-streaming':t==='falsetrue'?'server-streaming':'bidi-streaming';\n  if (!SUPPORTED.has(type)) throw new Error(`Unsupported method type: ${type}`);\n  return type;\n}","typeGuard":"function isWellFormedGrpcMethod(m): m is { requestStream:boolean; responseStream:boolean; requestSerialize:Function; responseDeserialize:Function } {\n  return !!m && typeof m.requestStream==='boolean' && typeof m.responseStream==='boolean' && typeof m.requestSerialize==='function' && typeof m.responseDeserialize==='function';\n}","tryCatchPattern":"try { this.#handleConnection(options); }\ncatch (e) { if (/Unsupported method type/.test(e.message)) { await this.#refreshMethods({...}); /* retry once */ } else throw e; }","preventionTips":["Always resolve methods via reflection or a fresh proto parse; never trust serialized method objects from local storage that lost their functions.","Validate the method object's stream flags before dispatch.","Re-import the proto whenever the service definition changes."],"tags":["grpc","streaming","method-dispatch","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}