DEV Community

Cover image for How to Fix an Error within Minutes with Sentry and GitAuto
Wes Nishio for GitAuto

Posted on • Originally published at gitauto.ai

How to Fix an Error within Minutes with Sentry and GitAuto

How to Fix an Error within Minutes with Sentry and GitAuto

Let's walk through fixing an error caught by Sentry using GitAuto. We'll cover the process from error detection to pull request creation.

Sentry is an error monitoring platform like Rollbar, Datadog, and New Relic.

TL;DR - Quick Steps

  1. Identifying the Error in Sentry
  2. Creating a GitHub Issue
  3. Using GitAuto to Fix the Error
  4. Understanding Root Causes
  5. Sentry-GitHub Integration

1. Identifying the Error in Sentry

Our Sentry dashboard shows a TypeError with the message 'NoneType' object is not iterable. The error occurs in:

/var/task/services/github/comment_manager.py in filter_my_comments at line 42
Enter fullscreen mode Exit fullscreen mode

This is a common Python error that occurs when we try to iterate over None instead of an iterable object (like a list or tuple).

Sentry error details 1

Sentry error details 2

2. Creating a GitHub Issue

Copy the essential information from Sentry and create a new GitHub issue. Include:

  • Error type: TypeError: 'NoneType' object is not iterable
  • File location: comment_manager.py
  • Function name: filter_my_comments
  • Line number: 42

Creating a GitHub issue with Sentry error details

Created a GitHub issue with Sentry error details

Don't worry if you're unsure which parts of the error are most relevant - it's completely normal! In such cases, feel free to copy and paste the entire error log. While screenshots can work too since they're readable for GitAuto, it's better to paste the actual text when available as it will be more searchable and machine-readable.

3. Using GitAuto to Fix the Error

After assigning GitAuto to the issue, it analyzes the error and creates a pull request with a fix. Here's the diff:

GitAuto pull request Conversation tab

GitAuto pull request Files changed tab

4. Understanding Root Causes

While the immediate fix works, it's worth understanding why we're receiving None instead of a list. In this case, there's actually a deeper root cause that wouldn't be obvious from just the error message alone.

This function is part of GitAuto's comment cleanup operation - it runs when GitAuto starts up, fetches issue comments, and cleans up any previous comments made by GitAuto itself. The error occurred because the input came from Atlassian Jira instead of GitHub Issues, resulting in comments being None. This slipped through because Cursor editor didn't catch it, Python isn't as type-strict as TypeScript, and I wasn't aware of it until the error was caught by Sentry.

While we could solve this by adding an if-statement upstream to check whether the input is from GitHub or Jira, this raises an interesting question: what's the "real" root cause fix? The answer isn't straightforward - it depends entirely on your requirements and personal judgment.

5. Sentry-GitHub Integration

Sentry offers GitHub integrations that can streamline this process:

Basic Integration (Free)

  • You can manually copy and paste error details from Sentry to GitHub

Team Plan

  • You can one-click GitHub issue creation from Sentry
  • You can easily transfer error details from Sentry to GitHub
  • So, you can easily assign GitAuto to the issue without manually creating a GitHub issue

Business Plan

  • You can automatically create GitHub issues on error detection
  • You can customize labels for GitHub issues with gitauto
  • The gitauto label will trigger GitAuto to fix the error automatically
  • So, you will have a complete automation pipeline from error detection to pull request creation

For detailed pricing and features, please check Sentry's pricing page. * We are not affiliated with Sentry.

When to Use GitAuto vs Other Tools

If you're an engineer who analyzes, fixes, and tests errors yourself, AI pair programming tools like GitHub Copilot or Cursor might be more suitable. These IDE-integrated tools work directly with you as you code.

However, if you're an Engineering Manager or Scrum Master who assigns tasks rather than fixes them directly, GitAuto offers a different value proposition. After assigning more priority tickets to your human engineers, you can delegate remaining bug tickets to coding agents like GitAuto. Since pull requests are created quickly, you can immediately assign reviewers and keep the development pipeline moving.

Conclusion

While fixing a TypeError can be as simple as adding a null check, understanding the context and root cause helps make better architectural decisions. Tools like Sentry and GitAuto can significantly streamline the debugging and fixing process, especially when integrated together.

Remember: The "best" fix often depends on your specific requirements. Sometimes a quick null check is sufficient; other times, you might want to implement more robust input validation or type checking.

Have questions about fixing type errors with GitAuto? Feel free to reach out through our chat support or email us at info@gitauto.ai.

Top comments (0)