Automated Build Failure Analysis with Log Detective in Packit

Overview

If you've ever faced a cryptic package build failure in Fedora's Koji build system, you know the frustration of sifting through thousands of lines of logs. Log Detective, now integrated with Packit, offers a helping hand. It automatically analyzes failed Koji scratch builds triggered by Packit on dist-git pull requests, providing a human-readable explanation and even a suggested fix. This tutorial walks you through what Log Detective does, how to take advantage of it, and what to watch out for—even though it requires zero configuration on your part.

Automated Build Failure Analysis with Log Detective in Packit
Source: fedoramagazine.org

Prerequisites

Before diving in, ensure you have the following in place:

Step-by-Step: How a Build Failure Triggers Log Detective

The entire process is automatic. Here’s what happens behind the scenes and what you’ll see as a user.

1. Configure Packit (If Not Already Done)

Although no special Log Detective configuration is needed, you must have a working packit.yaml file in your dist-git repository that enables Koji scratch builds. Below is a minimal example.

# packit.yaml
specfile: mypackage.spec
jobs:
  - job: scratch_build
    trigger: pull_request
    metadata:
      targets:
        - fedora-all

This tells Packit to perform a scratch Koji build for every pull request. If the build fails, Log Detective will automatically analyze the logs.

2. Submit a Pull Request That Causes a Build Failure

Create a pull request in your dist-git repository. For this tutorial, introduce an intentional error in the spec file, e.g., a missing BuildRequires or a syntax error. Once submitted, Packit will trigger a scratch build on Koji.

3. Automatic Analysis Request

When the build fails, Packit automatically sends a request to the Log Detective interface server. This server is a lightweight, containerized service that orchestrates the analysis.

4. Retrieving and Displaying Results

Once the analysis finishes, the interface server posts the results on the Fedora Messaging bus. Packit listens for these messages and links the analysis to the corresponding pull request in the Dashboard.

The analysis is derived solely from the build logs; Log Detective does not consult external sources like bug trackers or package metadata.

Automated Build Failure Analysis with Log Detective in Packit
Source: fedoramagazine.org

Code Example: Example Analysis Response (JSON)

While you won't see raw JSON in the Dashboard, the internal API returns something like this. This is for illustration only.

{
  "analysis_id": "abc123",
  "status": "completed",
  "statement": "Build failed because the required tool 'cmake' is not found in the build environment.",
  "suggestion": "Ensure 'cmake' is listed in BuildRequires in the spec file."
}

You'll see a human-readable version of this on your PR page.

Common Mistakes & Misconceptions

Future Development

The Log Detective service is under active development. Planned improvements include:

Stay tuned to the Packit project for updates.

Summary

Log Detective in Packit eliminates the tedious log-diving that follows a failed Koji scratch build. By automatically extracting informative snippets using the Drain algorithm and an AI agent, it provides a concise explanation and a fix suggestion—all without any manual effort. While it's not perfect and won't replace deep packaging expertise, it's a powerful aid for both novices and busy maintainers. Just ensure your Packit integration is active, and let Log Detective do the heavy lifting.

Recommended

Discover More

Go Developer Survey 2025: Key Insights and Trends5 Key Optimizations That Made JSON.stringify Twice as Fast in V8Microsoft's API Management Platform Named Leader for AI-Driven IntegrationJuno's Glimpse of Thebe: A Tiny Moon of Jupiter10 Essential Markdown Tips for GitHub Newcomers