Skip to content

Do not create AI summary for MR with empty extracted diffs

Patrick Bajao requested to merge 435627-no-summary-for-empty-diffs into master

What does this MR do and why?

When we send a request to AI to summarize merge request but the diff is empty, we send the prompt with an empty diff to summarize and it can respond with irrelevant summary.

To prevent that, we don't make a request to AI when diff is empty and if the extracted diff we use for the prompt is blank (e.g. diff contains binary files only).

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Required: https://docs.gitlab.com/ee/development/ai_features/index.html#test-saas-only-ai-features-locally

Two different scenarios:

MR with empty commit

  1. Create a MR with no commits.
  2. Push an empty commit.
  3. Confirm that no diff summary is generated (you don't see the Latest AI-generated summary section above MR description).

MR that contains binary files only

  1. Create a MR with files that are binary files only (e.g. upload an image).
  2. Confirm that no diff summary is generated (you don't see the Latest AI-generated summary section above MR description).

Related to #435627 (closed)

Edited by Patrick Bajao

Merge request reports