Skip to content

Try to detect if JIRA v8 server is not using the Createmeta REST endpoint #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 18, 2023
Merged

Try to detect if JIRA v8 server is not using the Createmeta REST endpoint #574

merged 5 commits into from
Mar 18, 2023

Conversation

tristianc
Copy link
Contributor

@tristianc tristianc commented Feb 16, 2023

When I try to log into our JIRA instance, I get:

⠸ Verifying login details...

REQUEST DETAILS
------------------------------------------------------------

GET /rest/api/2/myself HTTP/1.1
Host: jira.instance
Authorization: Basic AAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaa1111111

⠙ Fetching server details...

REQUEST DETAILS
------------------------------------------------------------

GET /rest/api/2/serverInfo HTTP/1.1
Host: jira.instance
Authorization: Basic AAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaa1111111

⠹ Fetching projects...

REQUEST DETAILS
------------------------------------------------------------

GET /rest/api/2/project?expand=lead HTTP/1.1
Host: jira.instance
Authorization: Basic AAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaa1111111

⠹ Fetching boards for project 'CD'...

REQUEST DETAILS
------------------------------------------------------------

GET /rest/agile/1.0/board?projectKeyOrId=CD HTTP/1.1
Host: jira.instance
Authorization: Basic AAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaa1111111

⠹ Configuring metadata. Please wait...

REQUEST DETAILS
------------------------------------------------------------

GET /rest/api/2/issue/createmeta?projectKeys=CD&expand=projects.issuetypes.fields HTTP/1.1
Host: jira.instance
Authorization: Basic AAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaa1111111


✗ Unable to generate configuration: Get "https://jira.instance/rest/api/2/issue/createmeta?projectKeys=CD&expand=projects.issuetypes.fields": 303 response missing Location header

This is with commit 6085aee, committed on February 13th.

When I attempted to try the last endpoint (/rest/api/2/issue/createmeta?projectKeys=CD&expand=projects.issuetypes.fields) myself in a browser manually, I get:

This endpoint is disabled by the administrator. Please refer to https://confluence.atlassian.com/adminjira/createmeta-rest-endpoint-to-be-removed-975014604.html

The behavior of our v8 instance matches the default behavior of JIRA v9, which the CLI already accomodates. This tries to detect if the v9 behavior should be used for v8.

Copy link
Owner

@ankitpokhrel ankitpokhrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tristianc, thank you for the fix.

As per the docs, it seems like this new endpoint is already available in 8.4.

That is why we decided to remove this endpoint in Jira 9.0. Until then you can disable it and 
replace it with the other calls we've created and made available in Jira 8.4 to remedy the issue. 

Since the new endpoint is already available in Jira v8.4, I think it is safe to change the version comparison in line 472 to make it work above v8.4.

isV9Compatible := c.value.version.major >= 9 || (c.value.version.major == 8 && c.value.version.minor >= 4)
if c.value.installation == jira.InstallationTypeLocal && isV9Compatible {
    err = c.configureIssueTypesForJiraServerV9()
} else {
    ...
}

@@ -473,6 +473,13 @@ func (c *JiraCLIConfigGenerator) configureMetadata() error {
err = c.configureIssueTypesForJiraServerV9()
} else {
err = c.configureIssueTypes()
if err != nil {
if e, ok := err.(*url.Error); ok {
if e.Err.Error() == "303 response missing Location header" && c.value.version.major == 8 && c.value.version.minor >= 4 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required only for the local installation

@ankitpokhrel ankitpokhrel merged commit b5fd861 into ankitpokhrel:main Mar 18, 2023
@ankitpokhrel
Copy link
Owner

Thank you @tristianc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants