Merge Request with non-existent target branch shows no diffs and provides poor error messaging
Description
When a merge request is created targeting a branch that doesn't exist, the MR shows no diffs and provides confusing error states without clearly indicating the root cause.
Steps to Reproduce
- Have a project with default branch
masterthat has commits - Create a merge request via API with
source_branch: feature/my-featureandtarget_branch: main(wheremaindoesn't exist) - The MR is created successfully but shows:
"diff_refs": null"has_conflicts": true"changes_count": null- No diffs visible in UI
- No clear indication that the target branch doesn't exist
Expected Behavior
- The API should validate that the target branch exists and return a clear error (400 Bad Request) if it doesn't
- If the MR is somehow created, the UI should clearly indicate "Target branch 'main' does not exist"
- GitLab Duo Chat/Agents should be aware of the project's default branch and prevent targeting non-existent branches
Actual Behavior
- MR is created successfully despite targeting a non-existent branch
- No clear error message about missing target branch
- User must manually discover the issue and change target branch
- The MR appears broken with no explanation
Workaround
Update the MR to target an existing branch (e.g., master)
Impact
- Confusing for GitLab Duo Chat users who may not know the project's branch structure
- Wastes time debugging what appears to be a GitLab bug
- Poor API validation allows invalid state
Environment
- GitLab Version: 18.10.0 (GitLab.com SaaS)
- API Version: v4
Additional Context
Issue text was generated by GitLab Duo Chat (Claude Sonnet 4.5 - Anthropic model)
Edited by 🤖 GitLab Bot 🤖