Skip to content

Conversation

@JoshFerge
Copy link
Member

Summary

Fixes AIML-2353

When branch_name is an empty string, the Cursor API returns an error:

"Git ref (branch/tag) cannot be an empty string"

This affects ~50% of Seer project preferences where users intentionally leave branch_name blank, expecting Seer to use the repo's default branch (as per the UI copy: "if left blank Seer will look at the default branch of the repository").

Root Cause

  • Repos stored in Seer preferences can have branch_name="" (empty string)
  • The Cursor client passed branch_name directly to ref
  • Empty strings weren't excluded by exclude_none=True (only None is excluded)
  • Cursor API received "ref": "" and failed validation

Fix

Convert empty/falsy branch_name to None:

ref=request.repository.branch_name or None

This causes the field to be excluded from the JSON payload, allowing Cursor to automatically resolve to the repository's default branch.

Verified with Cursor API

# Empty string → Error
curl ... --data '{"source": {"repository": "...", "ref": ""}}'
# {"error": "Invalid creation request parameters", "details": [{"message": "Git ref (branch/tag) cannot be an empty string"}]}

# Omitted → Success (resolves to default branch)  
curl ... --data '{"source": {"repository": "..."}}'
# {"source": {"ref": "main"}, ...}  ✓

Test plan

  • Added tests for empty string and None branch_name cases
  • Verified existing tests still pass
  • Manually tested against Cursor API

When `branch_name` is an empty string, the Cursor API returns an error:
"Git ref (branch/tag) cannot be an empty string"

This affects ~50% of Seer project preferences where users intentionally
leave branch_name blank, expecting Seer to use the repo's default branch.

The fix converts empty/falsy `branch_name` to `None`, which gets excluded
from the JSON payload via `exclude_none=True`, allowing Cursor to
automatically resolve to the repository's default branch.

Fixes: Seer fails when invoking Cursor agent with empty source.ref
@linear
Copy link

linear bot commented Jan 24, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 24, 2026
@JoshFerge
Copy link
Member Author

@sentry review
bugbot review

@JoshFerge
Copy link
Member Author

bugbot review

@JoshFerge
Copy link
Member Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants