{"record":{"id":"d5ed001bebbc60eb","repo":"ToolJet/ToolJet","slug":"service-servicename-not-found-in-proto-file","errorCode":null,"errorMessage":"Service ${serviceName} not found in proto file","messagePattern":"Service (.+?) not found in proto file","errorType":"exception","errorClass":"GrpcOperationError","httpStatus":null,"severity":"error","filePath":"plugins/packages/grpcv2/lib/operations.ts","lineNumber":113,"sourceCode":"    const cleanUrl = sanitizeGrpcServerUrl(sourceOptions.url, sourceOptions.ssl_enabled);\n    const ServiceConstructor = service as new (url: string, credentials: any) => GrpcClient;\n    const grpcClient = new ServiceConstructor(cleanUrl, credentials);\n\n    return grpcClient;\n  } catch (error: unknown) {\n    const err = toError(error);\n    throw new GrpcOperationError(`Failed to create reflection client for service ${serviceName}: ${err.message}`, error);\n  }\n};\n\nexport const buildProtoFileClient = async (sourceOptions: SourceOptions, serviceName: string): Promise<GrpcClient> => {\n  try {\n    const packageDefinition = await loadProtoFromRemoteUrl(sourceOptions.proto_file_url!);\n    const grpcObject = grpc.loadPackageDefinition(packageDefinition);\n\n    const service = findServiceInPackage(grpcObject, serviceName);\n    if (!service) {\n      throw new GrpcOperationError(`Service ${serviceName} not found in proto file`);\n    }\n\n    const credentials = buildChannelCredentials(sourceOptions);\n    const cleanUrl = sanitizeGrpcServerUrl(sourceOptions.url, sourceOptions.ssl_enabled);\n\n    if (typeof service !== 'function') {\n      throw new GrpcOperationError(`Service ${serviceName} is not a valid constructor function`);\n    }\n    // Type assertion necessary for constructor function interface\n    const ServiceConstructor = service as new (url: string, credentials: any) => GrpcClient;\n    const client = new ServiceConstructor(cleanUrl, credentials);\n    return client;\n  } catch (error: unknown) {\n    if (error instanceof GrpcOperationError) {\n      throw error;\n    }\n    const err = toError(error);\n    throw new GrpcOperationError(`Failed to create proto file client for service ${serviceName}: ${err.message}`, error);","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/plugins/packages/grpcv2/lib/operations.ts#L95-L131","documentation":"Thrown in buildProtoFileClient after loadProtoFromRemoteUrl + loadPackageDefinition succeed but findServiceInPackage(grpcObject, serviceName) returns null. The proto file downloaded and parsed, but the requested service name is not present in the loaded package definition. This is a name mismatch against the actual contents of the remote .proto.","triggerScenarios":"sourceOptions.proto_file_url points to a valid proto that does not declare serviceName; a short name used where the proto uses a fully-qualified name; wrong proto file URL for the intended service; proto uses a different package than expected.","commonSituations":"URL points to a proto for a different microservice; service renamed in the proto; package prefix not included in the lookup; multiple proto files and the wrong one was configured.","solutions":["Inspect the .proto at proto_file_url and confirm the exact service name and package it declares.","Use the fully-qualified service name (package.service).","Point proto_file_url to the correct proto file that actually defines the service."],"exampleFix":"// before\nsourceOptions.proto_file_url = 'https://host/user-v1.proto';\nserviceName = 'UserService';\n// after (proto declares package acme; service UserService)\nserviceName = 'acme.UserService';","handlingStrategy":"validation","validationCode":"async function verifyServiceInProtoUrl(url: string, serviceName: string) {\n  const protoLoader = require('@grpc/proto-loader');\n  const grpc = require('@grpc/grpc-js');\n  const def = await protoLoader.load(url);\n  const obj = grpc.loadPackageDefinition(def);\n  const walk = (o: any, prefix = ''): string[] => {\n    const out: string[] = [];\n    for (const [k, v] of Object.entries(o)) {\n      if (typeof v === 'function') out.push(prefix + k);\n      else if (v && typeof v === 'object') out.push(...walk(v, prefix + k + '.'));\n    }\n    return out;\n  };\n  const names = walk(obj);\n  if (!names.includes(serviceName)) throw new Error(`${serviceName} not in ${url}. Found: ${names.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the proto at proto_file_url declares the intended service and package.","Use fully-qualified names matching the proto's package directive.","Cache the correct proto_file_url per service to avoid pointing at the wrong file."],"tags":["proto-file","name-resolution","configuration","proto"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}