From e0dc7ac0b819be75a84f352bf4f78d7c1458c6db Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 9 May 2026 00:24:28 +0200 Subject: [PATCH] fix(api): return 404 for workflow lookup on repo with empty default branch Under the gogit build tag, an empty repo.DefaultBranch causes GetBranchCommit to fail go-git's reference-name validation with an "invalid reference name" error that does not unwrap to util.ErrNotExist, so the workflow runs API returns 500 instead of 404. Short-circuit when DefaultBranch is empty to match GitHub's 404 for missing workflows. Co-Authored-By: Claude (Opus 4.7) --- services/convert/convert.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/convert/convert.go b/services/convert/convert.go index 744153d8c3..259ce13dd9 100644 --- a/services/convert/convert.go +++ b/services/convert/convert.go @@ -596,6 +596,9 @@ func ListActionWorkflows(ctx context.Context, gitrepo *git.Repository, repo *rep } func GetActionWorkflow(ctx context.Context, gitrepo *git.Repository, repo *repo_model.Repository, workflowID string) (*api.ActionWorkflow, error) { + if repo.DefaultBranch == "" { + return nil, util.NewNotExistErrorf("workflow %q not found", workflowID) + } defaultBranchCommit, err := gitrepo.GetBranchCommit(repo.DefaultBranch) if err != nil { return nil, err