jiralert icon indicating copy to clipboard operation
jiralert copied to clipboard

Cookie Based Auth: Unable to use Jira API without a session ID

Open barrigas opened this issue 3 years ago • 4 comments

Once Jiralert starts, it produces the following output:

handleJiraError: api=Issue.Search, url=https://company-name.atlassian.com/rest/api/2/search?jql=project%3D%22TEST%22+and+labels%3D%22ALERT%7D%22+order+by+resolutiondate+desc&startAt=0&maxResults=2&expand=&fields=summary,status,resolution,resolutiondate&validateQuery=, **err=The value 'TEST' does not exist for the field 'project'.: Request failed. Please analyze the request body for more details. Status code: 400**

500 Internal Server Error: err=JIRA request https://company-name.atlassian.com/rest/api/2/search?jql=project%3D%22TEST%22+and+labels%3D%22ALERT%7D%22+order+by+resolutiondate+desc&startAt=0&maxResults=2&expand=&fields=summary,status,resolution,resolutiondate&validateQuery= **returned status 400 Bad Request**, body "" receiver="default" groupLabels=map[]

This is a known error.

It seems that JSESSIONID is necessary, which can also be passed in the URL (Reference: https://developer.atlassian.com/server/jira/platform/cookie-based-authentication/)

However, it needs to be after the URL path which is not possible in the jiralert.yml config file.

Is there a solution or workaround for this?

Thank you.

barrigas avatar Mar 03 '21 12:03 barrigas

Hey I'm sorry to hear that, but for now jiralert only support basic auth. Happy to see a PR though :)

erdii avatar Mar 05 '21 12:03 erdii

Do we have a workaround here ? I hit the same. Any improvements or workarounds ? Request:

curl -H "Content-type: application/json" -X POST   -d '{"receiver": "jiralert", "status": "firing", "alerts": [{"status": "firing", "labels": {"alertname": "TestAlert", "key": "value"} }], "groupLabels": {"alertname": "TestAlert"}}'   http://localhost:9097/alert

Error:

level=debug ts=2021-09-10T14:38:24.24537918Z caller=main.go:87 msg="handling /alert webhook request"
level=debug ts=2021-09-10T14:38:24.245606042Z caller=main.go:102 msg="  matched receiver" receiver=jiralert
level=debug ts=2021-09-10T14:38:24.245646628Z caller=template.go:69 msg="executing template" template=TEST
level=debug ts=2021-09-10T14:38:24.245666121Z caller=template.go:71 msg="returning unchanged"
level=debug ts=2021-09-10T14:38:24.245746889Z caller=notify.go:270 msg=search query="project=\"TEST\" and labels=\"JIRALERT{c2c09f9c14d39d81e67bf00ec0b041d3cfe3505c5ffe2f81b737272938a26246dac498b48c6c5dbc770f464f2b878b4678cbd716ace7d896ff7857e7d6c24dbd}\" order by resolutiondate desc" options="&{StartAt:0 MaxResults:2 Expand: Fields:[summary status resolution resolutiondate] ValidateQuery:}"
level=debug ts=2021-09-10T14:38:24.338967478Z caller=notify.go:382 msg=handleJiraErrResponse api=Issue.Search err="The value 'TEST' does not exist for the field 'project'.: request failed. Please analyze the request body for more details. Status code: 400" url="https://company.atlassian.net/rest/api/2/search?fields=summary%2Cstatus%2Cresolution%2Cresolutiondate&jql=project%3D%22TEST%22+and+labels%3D%22JIRALERT%7Bc2c09f9c14d39d81e67bf00ec0b041d3cfe3505c5ffe2f81b737272938a26246dac498b48c6c5dbc770f464f2b878b4678cbd716ace7d896ff7857e7d6c24dbd%7D%22+order+by+resolutiondate+desc&maxResults=2"
level=error ts=2021-09-10T14:38:24.339397414Z caller=main.go:164 msg="error handling request" statusCode=500 statusText="Internal Server Error" err="JIRA request https://company.atlassian.net/rest/api/2/search?fields=summary%2Cstatus%2Cresolution%2Cresolutiondate&jql=project%3D%22TEST%22+and+labels%3D%22JIRALERT%7Bc2c09f9c14d39d81e67bf00ec0b041d3cfe3505c5ffe2f81b737272938a26246dac498b48c6c5dbc770f464f2b878b4678cbd716ace7d896ff7857e7d6c24dbd%7D%22+order+by+resolutiondate+desc&maxResults=2 returned status 400 Bad Request, body \"\"" receiver=jiralert groupLabels="unsupported value type"

occelebi avatar Sep 10 '21 14:09 occelebi

I am going to create a PR very soon. We've got a working solution here for quite some time and I just need to polish the code a bit.

ju-la-berger avatar Nov 05 '21 12:11 ju-la-berger

Hi! I have a same issue, Are there any resolution?

level=error ts=2023-01-11T18:54:42.942302145Z caller=main.go:173 msg="error handling request" statusCode=500 statusText="Internal Server Error" err="JIRA request https://sancristo.atlassian.net/rest/api/2/search?fields=summary%2Cstatus%2Cresolution%2Cresolutiondate&jql=project%3D%22AL%22+and+labels%3D%22ALERT%7Balertname%3D%5C%22TestAlert%5C%22%7D%22+order+by+resolutiondate+desc&maxResults=2 returned status 401 Unauthorized, body \"\"" receiver=jiraalert groupLabels="unsupported value type" level=error ts=2023-01-11T18:56:49.773414961Z caller=main.go:173 msg="error handling request" statusCode=500 statusText="Internal Server Error" err="JIRA request https://sancristo.atlassian.net/rest/api/2/search?fields=summary%2Cstatus%2Cresolution%2Cresolutiondate&jql=project%3D%22AL%22+and+labels%3D%22ALERT%7Balertname%3D%5C%22TestAlert%5C%22%7D%22+order+by+resolutiondate+desc&maxResults=2 returned status 401 Unauthorized, body \"\"" receiver=jiraalert groupLabels="unsupported value type"

nicosistemas avatar Jan 11 '23 19:01 nicosistemas