Troubleshoot bug predict

Before you start

Bug prediction scans your codebase for patterns that historically cause production incidents — dangerous_eval, broad_exception, and incomplete_code — and returns a risk report scored 0–100. The workflow coordinates three subagents (pattern-scanner, risk-correlator, prevention-advisor) and formats output through format_bug_predict_report(). Failures can occur at the workflow, subagent, or report-formatting layer.

Symptom table

If you observe Check
BugPredictionWorkflow.execute() raises an exception Read the full traceback — it names the file and line. Check whether the path argument resolves to a real directory before calling execute().
The report is empty or shows 0 findings on a path that should have issues Confirm the scanned path contains .py files. If it does, check whether all findings are being suppressed by the false-positive filter (look for # INTENTIONAL:, # noqa: BLE001, or _INTENTIONAL_KEYWORDS matches).
format_bug_predict_report() returns garbled or incomplete output Verify that the result dict passed to format_bug_predict_report(result, input_data) is the unmodified return value of execute(). A partial or manually constructed dict can omit required keys.
The CLI entry point (main()) exits without output Run with a path argument and check stderr for an error message. main() is the CLI entry point — it does not return a value, so silent exit usually means the path was not found or was empty.
Risk score is unexpectedly low despite known risky patterns Check whether the flagged files match any of the test-file patterns (test_bug_predict, test_scanner, test_security_scan). Test files are excluded from scoring.
Behavior differs between two runs on the same code Look for environment drift: changed files, a dependency upgrade, or a different working directory affecting relative path resolution.

Step-by-step diagnosis

Work from cheapest to most invasive. Stop as soon as you find the cause.

  1. Reproduce against a minimal path. Call /bug-predict on a single file you control — for example, a file you know contains a bare except:. If the expected finding appears, the scanner is working and the issue is specific to your target path or environment.

    /bug-predict src/api/webhook.py
    
  2. Verify the path is reachable. Relative paths resolve from the working directory at the time execute() is called. Print or log the resolved path before passing it to BugPredictionWorkflow.execute() to rule out a working-directory mismatch.

  3. Check false-positive suppression. If findings disappear unexpectedly, review the code under scan for any of the suppression markers the scanner honors:

    • # INTENTIONAL: comments on broad-exception blocks
    • # noqa: BLE001 markers
    • Keywords from _INTENTIONAL_KEYWORDS: fallback, ignore, optional, best effort, graceful, intentional

    These are intentional suppressions — remove the marker if the suppression is wrong, not the pattern check.

  4. Run the related test suite.

    pytest -k "bug_predict" -v
    

    If a test exercises the failing path, its fixtures show you the expected input shape for BugPredictionWorkflow and format_bug_predict_report().

  5. Inspect format_bug_predict_report() inputs directly. If the report output is wrong but execute() succeeds, call format_bug_predict_report(result, input_data) in isolation with the raw result dict to confirm the formatting layer is the source. A malformed result dict is the most common cause of garbled report output.

  6. Check subagent completion. BugPredictionWorkflow coordinates three subagents: pattern-scanner, risk-correlator, and prevention-advisor. If the returned report is missing a section (Summary, Bugs, or Suggestions), one subagent likely did not complete. Look for timeout or error signals in the WorkflowResult before the report is formatted.

Common fixes

Source files

Tags: bugs, prediction, scanning