andygrunwald / andygrunwald/go-jira

Empty issue key causes misleading error

未关闭
#381 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
needs triage
主要语言
Go
星标
1.6k
派生
500
PR 合并指标
30 天内没有已合并 PR

描述

## Describe the bug

https://github.com/andygrunwald/go-jira/blob/v1.13.0/issue.go#L806 accepts empty issue keys which causes the resulting error to be:

```
405 Method Not Allowed: : request failed. Please analyze the request body for more details. Status code: 405
```

## To Reproduce

1. call [(*IssueService).Update](https://github.com/andygrunwald/go-jira/blob/v1.13.0/issue.go#L840) with no issue key set.

## Expected behavior

Should return `errors.New("invalid issue key")`

## Possible Solution

Validate the issue key before formatting:

```go
if err := ValidateIssueKey(issue.Key); err != nil {
return err
}
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", issue.Key)
//...
```

## Your Environment

* go-jira version (git tag or sha): v.1.13.0
* Go version (`go version`): go version go1.16.5 darwin/amd64

## Additional context

The error `405 Method Not Allowed` is misleading and doesn't reflect the actual error! Update shouldn't accept empty issue keys at all!
I suppose this isn't the only place in the code where similar things happen?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。