Serverless architectures, like AWS Lambda, offer incredible scalability and cost-efficiency. But they also introduce a unique challenge: managing errors. When a function fails, the error can be transient, buried in a sea of logs, and difficult to track. The context is often lost, and valuable time is spent manually creating bug reports instead of fixing the problem.
What if you could treat errors not just as log entries, but as actionable work items? What if you could manage issues like you manage your infrastructure—as code?
This is the core philosophy behind issues.do, the API for modern issue tracking. By integrating a simple API call into your serverless functions, you can automatically capture, assign, and prioritize issues the moment they happen, directly from your code.
This guide will walk you through a practical example of how to transform your serverless error handling from a reactive, manual process into a proactive, automated workflow.
In a typical serverless environment, an uncaught exception might trigger a CloudWatch alarm. From there, a developer on call has to:
This multi-step, context-switching process is inefficient and error-prone. Critical information gets lost, and the time between failure and fix grows.
issues.do allows you to short-circuit this entire manual process. By placing an API call directly within your function's error handling block, you create a rich, contextualized issue automatically.
Your error handling logic becomes a powerful new tool:
try {
// Your function's business logic
} catch (error) {
// 1. Log the error for observability
// 2. AUTOMATICALLY CREATE a detailed issue in issues.do
}
This "issues as code" approach ensures that no error goes unnoticed and that your development team gets everything they need to start working on a solution immediately.
Let's build a simple Node.js Lambda function that calls an unreliable external API. When that API fails, we'll automatically create an issue in issues.do.
First, install the issues.do SDK.
npm install @dotdo/sdk
# or
yarn add @dotdo/sdk
Next, ensure your Lambda function has access to your issues.do API key. The best practice is to store this as a secure environment variable (e.g., DOTDO_API_KEY).
Here is our example Lambda function. It attempts to fetch data, and if it fails, the catch block springs into action.
import { dotdo } from '@dotdo/sdk';
import { APIGatewayProxyHandler } from 'aws-lambda';
// Initialize the SDK. It will automatically look for DOTDO_API_KEY
// in the environment variables.
dotdo.init(process.env.DOTDO_API_KEY);
const callUnreliableService = async () => {
// This function simulates a call to an external service that might fail.
if (Math.random() > 0.5) {
throw new Error('API Rate Limit Exceeded');
}
return { data: 'Success' };
};
export const handler: APIGatewayProxyHandler = async (event) => {
try {
console.log('Attempting to call external service...');
await callUnreliableService();
return {
statusCode: 200,
body: JSON.stringify({ message: 'Operation successful!' }),
};
} catch (error) {
console.error('An unexpected error occurred:', error);
// --- AUTOMATED ISSUE CREATION WITH issues.do ---
try {
const newIssue = await dotdo.issues.create({
title: `Production Error: ${error.message} in FetchDataLambda`,
description: `The external weather API is returning an error. We need to investigate and potentially implement exponential backoff.
**Error Details:**
\`\`\`
${error.stack}
\`\`\`
**AWS Request ID:** \`${event.requestContext.requestId}\``,
assignee: 'dev-oncall@example.com',
priority: 'High',
labels: ['bug', 'production', 'serverless']
});
console.log(`Successfully created issue in issues.do: ${newIssue.id}`);
} catch (issueCreationError) {
// If creating the issue fails, log that failure so we know about it.
console.error('CRITICAL: Failed to create issue in issues.do:', issueCreationError);
}
// --- END ---
return {
statusCode: 500,
body: JSON.stringify({ message: 'An internal server error occurred.' }),
};
}
};
When this function is invoked and the callUnreliableService throws an error, the following happens instantly:
The on-call developer is notified immediately with all the context they need. The feedback loop is closed within milliseconds, not minutes or hours.
Automating error handling is just the beginning. With an API-first approach, you can integrate issues.do across your entire development lifecycle:
By shifting to an "issues as code" model, you streamline your development process, eliminate manual toil, and ensure that critical problems are addressed with speed and precision. issues.do provides the simple, powerful API to make it happen.
Ready to stop chasing logs and start fixing issues? Sign up for free at issues.do and integrate powerful, automated issue tracking into your workflow in minutes.