[Bug][Jira] Jira Server + SSO SAML: Fail to test connection
Search before asking
- [x] I had searched in the issues and found no similar issues.
What happened
My organization uses Jira Server + Okta SAML.
I added my PAT and Jira DC endpoint but got below error, so even though I saw Test connection successfully, this was the stack trace I saw in Network's tab:
I have redacted company related info for security purposes.
{
"code": 0,
"success": false,
"message": "attached stack trace\n -- stack trace:\n | github.com/apache/incubator-devlake/helpers/pluginhelper/api.UnmarshalResponse\n | \t/app/helpers/pluginhelper/api/api_client.go:437\n | [...repeated from below...]\nWraps: (2) error decoding response from https://<JIRA_HOST>/jira/plugins/servlet/samlsso/loggedin: raw response: \n |\n |\n |\n |\n |\n |\n | <!DOCTYPE html>\n | <html lang=\"en\" \n |\n |\n |\n |\n |\n |\n | data-theme=\"dark:dark light:light\" data-color-mode=\"dark\" >\n | <head>\n | \n |\n |\n |\n |\n |\n |\n |\n |\n |\n | <meta charset=\"utf-8\">\n | <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\"/>\n | <title>You are already logged in - Jira</title>\n | <meta name=\"application-name\" content=\"JIRA\" data-name=\"jira\" data-version=\"10.3.12\"><meta name=\"ajs-server-scheme\" content=\"https\"><meta name=\"ajs-server-port\" content=\"443\">\n | <meta name=\"ajs-server-name\" content=\"<JIRA_HOST>\">\n | <meta name=\"ajs-base-url\" content=\"https://<JIRA_HOST>/jira\">\n | <meta name=\"ajs-context-path\" content=\"/jira\">\n | <meta name=\"ajs-version-number\" content=\"10.3.12\">\n | <meta name=\"ajs-build-number\" content=\"10030012\">\n | <meta name=\"ajs-remote-user\" content=\"<USER_EMAIL>\">\n | <meta name=\"ajs-remote-user-fullname\" content=\"<USER_FULLNAME>\">\n | <meta name=\"ajs-user-locale\" content=\"en_US\">\n | ...\n | <meta id=\"atlassian-token\" name=\"atlassian-token\" content=\"<XSRF_TOKEN>\">\n | ...\n | <img src=\"https://<JIRA_HOST>/jira/secure/useravatar?size=small&avatarId=<AVATAR_ID>\" alt=\"User profile for <USER_FULLNAME>\"/>\n | ...\n | <a href=\"/jira/browse/<PROJECT_KEY>\" class=\"aui-nav-link ...\">Projects</a>\n | ...\n | <strong>You are already logged in.</strong>\n | ...\n | <input type=\"hidden\" title=\"baseURL\" value=\"https://<JIRA_HOST>/jira\" />\n | ...\n | <!--\n | REQUEST ID : <REQUEST_ID>\n | REQUEST TIMESTAMP : [<TIMESTAMP>]\n | REQUEST TIME : <REQUEST_TIME>\n | ASESSIONID : <ASESSIONID>\n | CONCURRENT REQUESTS : <N>\n | -- >\n |\n | </body>\n | </html>\n | (200)\nWraps: (3) attached stack trace\n -- stack trace:\n | github.com/apache/incubator-devlake/helpers/pluginhelper/api.UnmarshalResponse\n | \t/app/helpers/pluginhelper/api/api_client.go:431\n | github.com/apache/incubator-devlake/plugins/jira/api.queryJiraAgileBoards\n | \t/app/plugins/jira/api/remote_api.go:64\n | github.com/apache/incubator-devlake/plugins/jira/api.listJiraRemoteScopes\n | \t/app/plugins/jira/api/remote_api.go:100\n | github.com/apache/incubator-devlake/helpers/pluginhelper/api.(*DsRemoteApiScopeListHelper[...]).Get\n | \t/app/helpers/pluginhelper/api/ds_remote_api_scope_list_helper.go:78\n | github.com/apache/incubator-devlake/plugins/jira/api.RemoteScopes\n | \t/app/plugins/jira/api/remote_api.go:116\n | github.com/apache/incubator-devlake/server/api.handlePluginCall.func1\n | \t/app/server/api/router.go:141\n | github.com/gin-gonic/gin.(*Context).Next\n | \t/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174\n | github.com/apache/incubator-devlake/server/api.OAuth2ProxyAuthentication.func1\n | \t/app/server/api/middlewares.go:95\n | github.com/apache/incubator-devlake/server/api.RestAuthentication.func1\n | \t/app/server/api/middlewares.go:117\n | net/http.serverHandler.ServeHTTP\n | \t/usr/local/go/src/net/http/server.go:2936\n | net/http.(*conn).serve\n | \t/usr/local/go/src/net/http/server.go:1995\n | runtime.goexit\n | \t/usr/local/go/src/runtime/asm_arm64.s:1172\nWraps: (4) invalid character '<' looking for beginning of value\nWraps: (5) invalid character '<' looking for beginning of value\nError types: (1) *withstack.withStack (2) *errutil.withPrefix (3) *withstack.withStack (4) *errutil.withPrefix (5) *json.SyntaxError",
"causes": [
"invalid character '<' looking for beginning of value"
],
"data": null
}
It seems Jira fails to authenticate and redirects to our SSO probably.
What do you expect to happen
I expected the connection to pass, reason being that my below curl command worked and provided me my details and the board list with the PAT that I used for testing:
curl -i \
-H "Authorization: Bearer ${JIRA_PAT}" \
-H "Accept: application/json" \
"https://<jira-host>/jira/rest/api/2/myself"
curl -i -H "Authorization: Bearer ${JIRA_PAT}" \
"https://<jira-host>/jira/rest/agile/1.0/board?maxResults=1"
How to reproduce
Pre-requisite: May require Jira Server instance with SSO SAML.
- Create new Data Connection: Jira
- Select
Jira Server - Add PAT and endpoint URL
- Click "Test Connection" and check network logs
Anything else
No response
Version
v1.0.3-beta9@1410838
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
This happens because DevLake’s Jira plugin doesn’t handle SSO/SAML authentication flows—specifically, it doesn’t manage cookies between redirects. When Jira is behind SSO, DevLake’s API client sends the PAT, but if Jira responds with a redirect to an SSO login page, DevLake doesn’t keep the session cookies, so it ends up getting an HTML page instead of JSON, which causes the parsing error you saw. In contrast, curl preserves cookies and follows redirects in a single session, so the SSO flow completes and you get the expected JSON response source.
There’s no built-in workaround in DevLake for this. If possible, ask your Jira/SSO admin if API access with PATs can bypass SSO (sometimes there’s a special endpoint or network rule for this), or consider using a reverse proxy that handles SSO and presents a standard API to DevLake. If that’s not feasible, this is a current limitation of DevLake’s Jira integration with SSO/SAML source.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
@dosu first of all, the curl does not redirect to SSO, Jira validates the PAT internally. No cookies, no session is stored.
Secondly, DevLake is accidentally hitting a non-API SAML servlet (as shown in the stack trace attached), which always behaves like a browser endpoint. That servlet ignores Bearer tokens and assumes cookie-based SSO, so Jira returns an HTML page instead of JSON.
Could anyone please have a look at it?
You're right—DevLake does not intentionally hit the SAML servlet. The root cause is that DevLake builds Jira REST API calls by appending paths like api/2/serverInfo or agile/1.0/board directly to the endpoint you provide. If your endpoint does not end with /rest/, DevLake will construct URLs like https://<jira-host>/jira/agile/1.0/board, which are UI endpoints that redirect to the SAML servlet and return HTML instead of JSON. This is why your curl command works (it targets the correct REST API path), but DevLake fails when the endpoint is misconfigured.
To fix this, make sure your Jira endpoint in DevLake ends with /rest/ (for example: https://<jira-host>/jira/rest/). This will ensure all API calls go to the correct REST endpoints and avoid the SAML servlet redirect. There’s no hardcoded use of the SAML servlet in the plugin—this behavior is a side effect of the endpoint configuration logic. It would be helpful for the UI or docs to warn users if /rest/ is missing from the endpoint, since this is a common pitfall.
Let me know if updating the endpoint resolves the issue for you.
Reference: Jira plugin connection logic
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
@dosu you are right! I added /rest/ in the end of the endpoint url and it worked.
Should I close the issue?
Yes, you can close the issue. Adding /rest/ to the endpoint is the correct solution and is already checked by the plugin’s connection logic—if it’s missing, the code suggests appending it to avoid exactly this problem (source). If you think it would help others, you could leave a note or suggestion for improving the docs or UI, but there’s nothing else you need to do.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.