Avoiding Integration Bugs: Beyond SDKs & Contract Testing
Typed clients, contract tests and integration tests each catch a different kind of break.
Say you work at a fast-moving startup, where several services depend on each other and speed matters more than almost anything. You refactor an API, update the consumers you know about, and ship it. Then Slack lights up. An obscure downstream service that you didn’t know existed, or had forgotten about, has fallen over in production because it relied on the old API format. Or you changed a database column, and three hours later the analytics pipeline choked on it.
In a distributed system, integration points are the fault lines where things most often break, especially when teams are moving fast. Breaking changes will happen, and the challenge is preventing them from ever reaching production. Typed SDKs and contract testing are valuable safety nets, but they often leave dangerous gaps, so we need to shift further left and gain proactive, system-wide awareness.
What broken integrations cost, beyond downtime
Here are three hypothetical cases, each a different way an integration breaks.
The missed consumer
Your UserService renames the user_email field to the much clearer emailAddress, and you update the OrderService and NotificationService, the main consumers you remembered. But deep in the codebase there is a legacy ReportingService, built by a team long gone, that also consumed user_email. It breaks silently on the next deployment, and nobody finds out until the month-end reports fail, which sets off frantic debugging and emergency hotfixes.
The database ripple effect
The ProductService team sensibly decides to change the price column in their database from a potentially imprecise string to a proper decimal type, and they update their own service logic. But a downstream analytics service reads directly from a replica of that database. Its ETL jobs crash on the next run because they can’t parse the new data type, so the data warehouse goes stale and critical business reports are wrong.
The deployment race condition
AuthService deploys a critical security update that requires a new token format, which is a breaking change. They told the other teams ahead of time, and the APIService team prepared its update. But AuthService deploys at 2:00 PM, and because of a hiccup, APIService deploys its fix at 2:05 PM. For those five minutes, every user login attempt fails.
Downtime is only part of the cost. Breaks like these also mean lost revenue, potentially corrupted data, and engineering hours spent firefighting instead of building features. Over time they erode trust between teams (“Did they break us again?”).
There are several layers of defense against these breaks, and each one catches a different kind.
Typed client SDKs and code generation
Tools like tRPC (for TypeScript) or code generators based on OpenAPI/Swagger schemas promise type safety across API boundaries. You define your API schema and generate a client library from it. Consumers import the client and, ideally, get compile-time errors when they misuse the API, for example by passing the wrong type or reading a renamed field.
Within a compatible language ecosystem, such as full-stack TypeScript, the developer experience is excellent. Basic structural mismatches get caught early, and you get autocomplete.
The approach often falls apart in polyglot environments, though. A Python service calling a tRPC API gets none of its types, and with OpenAPI every language needs its own generated client. It depends on keeping schemas perfectly up to date and regenerating clients every time they change, and it adds complexity to the build tooling. It also usually catches only structural breaks, so subtle semantic or behavioral changes get through.
Here is what this might look like in practice. The @org/user-api package contains the schema and the generated client:
// 1. Define your API schema (this could be in OpenAPI/Swagger format too)
// userService.schema.ts
export interface User {
id: string;
emailAddress: string; // Previously was user_email
firstName: string;
lastName: string;
createdAt: Date;
}
// 2. Generate the client SDK
// userServiceClient.ts
export class UserServiceClient {
private baseUrl: string;
private headers: Record<string, string>;
constructor(baseUrl: string, apiKey: string) {
this.baseUrl = baseUrl;
this.headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
};
}
async getUser(userId: string): Promise<User> {
const response = await fetch(`${this.baseUrl}/users/${userId}`, {
method: 'GET',
headers: this.headers
});
if (!response.ok) {
throw new Error(`Failed to fetch user: ${response.statusText}`);
}
return response.json() as Promise<User>;
}
async createUser(user: Omit<User, 'id' | 'createdAt'>): Promise<User> {
const response = await fetch(`${this.baseUrl}/users`, {
method: 'POST',
headers: this.headers,
body: JSON.stringify(user)
});
if (!response.ok) {
throw new Error(`Failed to create user: ${response.statusText}`);
}
return response.json() as Promise<User>;
}
async updateUser(userId: string, userData: Partial<Omit<User, 'id' | 'createdAt'>>): Promise<User> {
const response = await fetch(`${this.baseUrl}/users/${userId}`, {
method: 'PATCH',
headers: this.headers,
body: JSON.stringify(userData)
});
if (!response.ok) {
throw new Error(`Failed to update user: ${response.statusText}`);
}
return response.json() as Promise<User>;
}
}
The OrderService uses the client like this:
import { UserServiceClient } from './userServiceClient';
class OrderService {
private userClient: UserServiceClient;
constructor(userServiceBaseUrl: string, apiKey: string) {
this.userClient = new UserServiceClient(userServiceBaseUrl, apiKey);
}
async createOrder(userId: string, items: any[]): Promise<any> {
// Get the user to associate with the order
const user = await this.userClient.getUser(userId);
// With typed SDK, this would be a type error if the field was renamed
console.log(`Creating order for ${user.emailAddress}`);
// Rest of order creation logic...
return {
orderId: 'ord_' + Math.random().toString(36).substr(2, 9),
userId: user.id,
customerEmail: user.emailAddress,
items
};
}
}
Reduced to the part that catches the rename:
// This would cause TypeScript error:
// Property 'user_email' does not exist on type 'User'.
function badConsumer(user: User) {
return user.user_email; // ❌ Compile-time error
}
// This works fine:
function goodConsumer(user: User) {
return user.emailAddress; // ✅ Safe
}
Contract testing and consumer-driven verification
Contract testing frameworks like Pact start from the other side of the API. The consumer defines how it expects to interact with the provider, meaning the requests it will send and the responses it expects. The consumer generates a “contract” file during its tests, and the provider runs that contract against its own code in its CI pipeline to make sure it meets the consumer’s expectations.
Because contracts are usually JSON, contract testing is language agnostic, so it works in the polyglot systems where typed clients fall apart. It verifies interactions against what consumers actually need, and it moves verification earlier, into the provider’s CI.
In return, it requires significant buy-in, coordination and discipline across teams, and setting up and maintaining the framework can be non-trivial. It mainly tests known consumer-provider pairs, so it won’t find that forgotten ReportingService. And if CI passes for both sides independently, the tests alone don’t stop incompatible versions from being deployed at the same time, unless every team also gates its deploys on a check like Pact’s can-i-deploy.
Integration testing across service boundaries
Client SDKs and contract tests create safety within controlled environments. Integration tests try to reproduce the chaos of production, where multiple services interact in complex ways. Unlike unit tests or mocked contract tests, they spin up actual instances of your services, connected to test databases, message queues and other dependencies, and exercise complete user journeys across system boundaries.
A robust integration test setup might look like this:
- Spin up containerized versions of UserService, OrderService, and PaymentService connected to isolated test databases.
- Trigger a complete user flow: register user → browse products → add to cart → checkout → receive confirmation.
- Verify that the end-to-end journey works AND that the data is consistent across all service boundaries.
Because integration tests run the services themselves, under conditions that more closely resemble production, they catch intricate timing issues, race conditions and subtle integration bugs that mock-based tests miss. They also build confidence in complex workflows that span multiple services.
That realism makes them significantly more complex to set up and maintain than contract tests, and they can be brittle and slow to run. Since the individual services have to be built first, integration tests often catch issues late in the development cycle, and they may still miss problems that only occur at production scale or with specific production data patterns.
Proactive impact analysis with Nimbus
Each of those layers checks part of the system. Proactive impact analysis aims to show the entire blast radius of a change before you merge the code, let alone deploy it.
Instead of looking at pairs of services or relying on generated code, tools like Nimbus build a comprehensive graph of your entire system. By statically analyzing code across all relevant repositories, and potentially infrastructure definitions, they map out services, APIs, data schemas, function calls and message flows.
Go back to the missed consumer. You, the UserService developer, rename user_email to emailAddress. As you prepare your pull request, or even while you type in your IDE, Nimbus analyzes the potential impact across the entire system graph. It flags the OrderService and NotificationService, and it also surfaces the incompatible usage in the long-forgotten ReportingService, so you see exactly which downstream consumers will break before your change merges.
Because it works from the whole graph, this approach can find impacted consumers that nobody documented, as long as the analysis has read their code. It catches issues before tests are written or contracts need to run, which is about as far left as a check can move, and it fits into the developer workflow through IDE feedback and PR checks. The analysis is language agnostic, since it is based on how services interact and not only on language types. It can potentially flag impacts beyond APIs too, such as direct database reads and message queue consumers.
Its effectiveness hinges on the accuracy and completeness of the static analysis model and the system graph, though. Complex, dynamic runtime behavior may still need complementary runtime checks.
Layering your defenses
These approaches complement each other. Typed SDKs provide an excellent first line of defense and a good developer experience within a consistent language stack. Contract tests are crucial for verifying behavior and compatibility between critical, known service pairs, especially across language boundaries. Integration tests validate user paths and complex interactions across multiple services, and they catch the timing issues and boundary problems that only emerge in realistic environments.
Impact analysis covers what those three leave out. As the system-wide safety net, it proactively discovers unknown impacts in the code it has read, and it catches breaks before CI.
Ship fast and safe
Stop relying on hope, manual checks or post-deployment firefighting to manage integration risk. Layer your defenses, and give particular weight to understanding the full impact of your changes before they merge. For teams that need to move fast without constantly breaking things, proactive, system-wide awareness from tools like Nimbus is becoming essential.