mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-13 00:16:07 +02:00
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) <noreply@anthropic.com>
This commit is contained in:
parent
89199c42d5
commit
e0dc7ac0b8
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user