Exclude invalid custom instructions from code review context

What does this MR do and why?

Fix the Duo Code Review context gathering step by ignoring invalid custom instructions.

If an invalid custom instruction is returned to AIGW, the build_review_merge_request_context step will fail and no context is passed to the LLM, turning the whole code review useless and generating a summary that does not reflect what happened.

This MR proactively excludes malformed custom instructions so that doesn't happen.

References

Fixes #601920 (closed).

How to set up and validate locally

In the master branch:

  1. Create a project with invalid custom instructions
    instructions:
      - name: "General insntructions"
        rules: "Do something"
  2. Create a MR and request a review from Duo
  3. Duo will try to build the review context and will fail because rules are invalid

Screenshot_2026-06-03_at_12.26.28

  1. Checkout this branch and try again. Duo should ignore the invalid instructions and build context as usual

MR acceptance checklist

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

Edited by Wanderson Policarpo

Merge request reports

Loading