Apidays India 2025

8-9 October

Chancery Pavilion Hotel, Bengaluru

Apidays India 2025

8-9 October

Chancery Pavilion Hotel, Bengaluru

gRPC Flaws​ – The Illusion of Safety & Frustrating DevEx in Proto3’s Type-Safe Contracts​

By Naresh Jain

Share this page

Understanding the Shortcomings of gRPC and How Contract Testing Can Bridge the Gap 

In the ever-evolving world of API design, development, and testing, the pursuit of a seamless developer experience (DevEx) remains a constant. This article sheds light on some of the overlooked pitfalls of gRPC, a popular choice for its performance capabilities and type-safe contracts. Discover the significant benefits of contract testing in addressing common issues and enhancing developer experience. 

Understanding gRPC and Its Promises – Type-Safety and Schema Enforcement 

gRPC has gained traction in the development landscape due to its promise of performance and the enforcement of type-safe contracts via protocol buffers (protobuf). It leverages proto files to define schemas, ensuring that data types and structures remain consistent across different services and platforms. This theoretically eradicates a multitude of problems, promoting backward and forward compatibility while automatically generating client and server code in various languages. 

The Reality Check: Identifying gRPC’s Flaws – Handling Requests and Responses 

Despite gRPC’s promise, we can demonstrate several important flaws in its operation. For example, let’s use a proto file called order BFF proto, that exhibits three RPC methods: FindAvailableProducts, CreateOrder, and CreateProduct. We can seamlessly create a product using the gRPC web UI. However, omitting crucial information prompts an unexpected response— the product is created successfully despite missing mandatory details. This revelation underscores an overlooked pitfall in gRPC: the lack of built-in support for mandatory parameters enforcement. 

Employing Validation Libraries 

Proto 3 dropped required fields here is the link to the related Github discussion. However, we can leverage external libraries such as buf.validate to define mandatory parameters. Updating the proto file to validate mandatory fields ensures that requests lacking essential information trigger appropriate validation errors. However, the scenario evolves in our demonstration when a product manager imposes a new constraint: inventory can only be in multiples of three. 

The Developer’s Dilemma – Code Changes and Proto File Mismatch 

A developer can incorporate this constraint directly into the code, checking if the inventory value adheres to the new rule. While the immediate implementation seems effective, a discrepancy arises—the constraint is absent from the proto file. This highlights a critical issue: the proto file is now out of sync with the actual implementation, leading to potential misunderstandings and errors for downstream consumers. 

The Role of Contract Testing 

Contract Test Implementation 

Contract testing is an effective remedy for such issues. Using the Specmatic framework, developers can write executable contract tests that verify the alignment between the proto file and the actual implementation. Specmatic automatically generates these tests, and upon execution in our demonstration, it reveals two critical test failures. One involves sending a request with an inventory not being a multiple of three, highlighting the previously unnoticed mismatch. 

Immediate Feedback and Resolution 

Specmatic’s feedback loop proves invaluable, instantly notifying developers of the discrepancy. This immediate feedback ensures that the proto file is updated in tandem with the implementation, preventing downstream misunderstandings and ensuring a consistent developer experience across the board. 

Conclusion: Embracing Contract-Driven Development 

A Better Developer Experience 

So, it is evident that while gRPC offers advantages, it is not without its flaws. The manual nature of validating mandatory fields and the potential misalignment between proto files and implementation can lead to a subpar developer experience. However, integrating contract-driven development practices, exemplified by Specmatic, can bridge these gaps. 

Collaboration and Consistency 

Maintaining a central Git repository for API specifications is essential. This ensures that all stakeholders—be they providers or consumers—operate with an up-to-date version of the specification. This approach eradicates discrepancies and fosters a culture of collaboration and consistency. 

The Path Forward 

Ultimately, embracing contract testing in conjunction with gRPC’s strengths paves the way for a more robust and developer-friendly API ecosystem. By addressing the flaws we have highlighted, developers can build more reliable, consistent, and efficient microservices, leading to enhanced productivity and faster deployment. 

Final Thoughts 

This demonstration serves as a reminder that even the most promising technologies can benefit from supplementary practices. Contract testing is not just a tool; it’s a paradigm that aligns implementation with intent, transforming gRPC’s potential into a reality that developers can rely on. 

Related Posts

specmaticmcpdemo linkedin mcp

By Hari Krishnan

Specmatic MCP as guardrails for Coding Agents: API Spec to Full Stack implementation in minutes

Table of Contents In this walkthrough we'll show how to use Specmatic MCP server for API testing (Contract and Resiliency) and Mocking as a guardrail
Read More
arazzo openapi asyncapi demo with specmatic

By Hari Krishnan

Authoring & Leveraging Arazzo Spec for OpenAPI & AsyncAPI Workflow Testing

Seamlessly test both synchronous and asynchronous APIs in realistic workflows before they ever hit production! Discover how combining OpenAPI and AsyncAPI specs can simplify complex
Read More
Arazzo API workflow demo

By Hari Krishnan

Visual Workflow Mocking and Testing with Specmatic and Arazzo API Specifications

Table of Contents API workflow testing with Arazzo and Specmatic: Visual authoring, workflow mocking, and backend verification Here we'll walk through a practical approach to
Read More
Specmatic vs Microcks comparison

By Hari Krishnan

Specmatic vs Microcks

When evaluating tools for API testing and mocking, the choice often comes down to understanding not just what each tool can do, but how their
Read More
jaydeep aws lambda

By Jaydeep Kulkarni

AWS Lambda Data Pipeline Testing using LocalStack with Specmatic

Table of Contents Mastering Testing AWS Lambda Functions with LocalStack and Specmatic With fast-evolving data ecosystems, building reliable and scalable data products is essential. One
Read More
api days revised 1920x1080

By John

New features and a BIG Announcement! Specmatic is bringing apidays to India!

In the past few months, we have launched a flurry of exciting features, presented at several global conferences and onboarded several new team members. We
Read More
Speakers presenting on API Governance at tech conference.

Update: See how Specmatic is transforming API testing & development

We've been hard at work, rolling out exciting new features and sharing the power of Specmatic and Contract Driven Development around the globe! Let's explore
Read More

By Joel Rosario

Build Apps from API specs using AI: Self-Correcting Contract-Driven Agentic Workflows with Specmatic

Harnessing the Power of API Specifications for Robust Microservices  Modern microservice architecture hinges on precise and dependable communication between services. This is where API specifications
Read More

OpenAPI Examples Simplified: Visualize and Generate Domain-Specific Test Data​

Streamlining API Development: An Interactive Guide to Example Generation and Validation using Specmatic  A robust, streamlined approach to API development is crucial for maintaining efficiency,
Read More

By Hari Krishnan

Pact’s Dependency Drag​: Why Consumer-Driven Contracts Don’t Support Parallel Development

Exploring the challenges and limitations of using Pact for contract testing in a microservices environment.  In the domain of microservices, ensuring seamless communication between different
Read More