Add diff_stats / changed files data to merge request webhook payload
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
The merge request webhook payload does not include any information about changed files (diff_stats). This data is available via the MR diff stats API (GET /projects/:id/merge_requests/:merge_request_iid/diffs) but requires a separate API call.
If we need to know which files were changed in an MR (e.g., for CI failure analysis, test selection, incident correlation) we must make additional API calls per MR, which is slow and subject to rate limits.
Proposal
Add a diff_stats field to the merge request webhook payload, similar to how last_commit is already included:
{
object_kind: merge_request,
object_attributes: {
...
diff_stats: [
{ path: app/models/user.rb, additions: 10, deletions: 3, new_file: false, renamed_file: false, deleted_file: false },
{ path: spec/models/user_spec.rb, additions: 25, deletions: 0, new_file: true, renamed_file: false, deleted_file: false }
]
}
}Use cases
- CI failure analysis: Correlating test failures with changed files to identify which changes likely caused the failure
- ML-based test selection: Training models that predict which tests to run based on changed files
- Incident detection: Identifying MR candidates that may have caused production incidents based on file path overlap
- Custom integrations: Any webhook consumer that needs to react to specific file changes without making additional API calls
Current workarounds
- API call after receiving the webhook (adds latency, rate limit risk)
- Run git diff in a CI job and collect the data separately (requires separate CI job)
Edited by 🤖 GitLab Bot 🤖