andygrunwald / andygrunwald/go-jira

Empty issue key causes misleading error

Ouverte
#381 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
needs triage
Langage dominant
Go
Étoiles
1.6k
Forks
500
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

## 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?

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.