jira-cli icon indicating copy to clipboard operation
jira-cli copied to clipboard

Unexpected response '404 Not Found' from jira.

Open xuanyuanaosheng opened this issue 3 years ago • 7 comments

Hey. I am really looking forward to use your program but got stuck on the init phase. Is it because of the oldness of my company's jira version or something else?

JiraCLI Version:

# jira version
(Version="1.1.0", GitCommit="3b93e147eac468ad985bdece27469153b4bb2814", CommitDate="2022-08-14T08:10:40+00:00", GoVersion="go1.18.3", Compiler="gc", Platform="linux/amd64")

Are you using Jira cloud or on-premise jira server? Also mention the version for on-premise installation. JIRA Service Desk 4.5.7
Jira Core 8.5.7 image What operating system are you using? Also mention version.

# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

What terminal are you using? Also mention version.

# bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

To Reproduce

Steps to reproduce the behavior:

# jira init --insecure 
You are using --insecure option. In this mode, the client will NOT verify
server's certificate chain and host name in requests to the jira server.

? Installation type: Local
? Link to Jira server: https://jira.prod
? Login username: test
? Default project: SR

✗ Received unexpected response '404 ' from jira. Please try again.

The related issue is: https://github.com/ankitpokhrel/jira-cli/issues/225

xuanyuanaosheng avatar Sep 08 '22 04:09 xuanyuanaosheng

Hi @xuanyuanaosheng, could you please run jira init --insecure --debug and see which call to the Jira API returns 404?

ankitpokhrel avatar Sep 08 '22 19:09 ankitpokhrel

Hi @xuanyuanaosheng, it looks like the board API is not accessible in your installation for some reason. Do you get a valid response back if you send a curl request?


curl --request GET \
  --url 'https://your_jira_host/rest/agile/1.0/board?projectKeyOrId=SR' \
  --user "<your_email_or_username>:$JIRA_API_TOKEN" \
  --header 'Accept: application/json'

I deleted your comment since you shared sensitive information. Please update your password.

ankitpokhrel avatar Sep 09 '22 07:09 ankitpokhrel

@ankitpokhrel The password field in comment, I have changed, So don't worry about it. The API return is also 404, I have tested it. I have ask our jira admin, It seems that this jira version has no board. Please help to check

xuanyuanaosheng avatar Sep 09 '22 10:09 xuanyuanaosheng

Hi @xuanyuanaosheng, just checked in Jira v8.5.7 (same as yours) and the API is available and working as expected. This seems to be something related with your installation.

ankitpokhrel avatar Sep 11 '22 08:09 ankitpokhrel

@ankitpokhrel We are using Jira Server Desk, Could you please help to test it?

xuanyuanaosheng avatar Sep 14 '22 02:09 xuanyuanaosheng

This has nothing to do with Jira Service Desk but it looks like you don't have agile add-on in your installation. The tool uses agile api for board, epic and sprints.

The init will fail at the moment if the API is not available. However, I think there should be a way to skip this when generating the config. I will see what I can do here.

ankitpokhrel avatar Sep 18 '22 18:09 ankitpokhrel

@ankitpokhrel OK, Thanks. Look forward to your new features.

image

xuanyuanaosheng avatar Sep 19 '22 03:09 xuanyuanaosheng

@ankitpokhrel Is this agile add-on can be installed after the installation?

xuanyuanaosheng avatar Sep 20 '22 07:09 xuanyuanaosheng

I don't know much about that. Please check with your Jira administrator.

ankitpokhrel avatar Sep 25 '22 08:09 ankitpokhrel

I have check with Jira administrator. The agile add-on can not be installed after the jira servicedesk installation @ankitpokhrel Any update about this issue ?

xuanyuanaosheng avatar Oct 25 '22 07:10 xuanyuanaosheng

@ankitpokhrel Any update ?

xuanyuanaosheng avatar Nov 14 '22 08:11 xuanyuanaosheng

Hi @xuanyuanaosheng, could you please check #502 resolves your issue? The PR makes boards optional for local installation.

You can install it with:

go install github.com/ankitpokhrel/jira-cli/cmd/jira@issue-464

// Or, with docker

docker pull ghcr.io/ankitpokhrel/jira-cli:issue-464

ankitpokhrel avatar Nov 19 '22 17:11 ankitpokhrel

@ankitpokhrel I have test it

# docker images
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY                             TAG         IMAGE ID      CREATED       SIZE
ghcr.io/ankitpokhrel/jira-cli          issue-464   5c8202d7c9c3  41 hours ago  23.8 MB

# jira version
(Version="issue-464", GitCommit="69256adc7de2448516487e889d3235d715f6c9b2", CommitDate="2022-11-19T17:09:00+00:00", GoVersion="go1.17.11", Compiler="gc", Platform="linux/amd64")

The error log is

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x7ca417]

goroutine 1 [running]:
net/http/httputil.DumpResponse(0x0, 0x0)
	/usr/local/go/src/net/http/httputil/dump.go:311 +0x37
github.com/ankitpokhrel/jira-cli/pkg/jira.dump(0xc0004c1540, 0xc0002a8700)
	/app/pkg/jira/client.go:260 +0x45
github.com/ankitpokhrel/jira-cli/pkg/jira.(*Client).request.func1()
	/app/pkg/jira/client.go:239 +0x2e
github.com/ankitpokhrel/jira-cli/pkg/jira.(*Client).request(0xc000476380, {0xf0d270, 0xc0000bc000}, {0xce8728, 0x3}, {0xc00029e400, 0x33}, {0x0, 0x0, 0x0}, ...)
	/app/pkg/jira/client.go:255 +0x6a5
github.com/ankitpokhrel/jira-cli/pkg/jira.(*Client).GetV2(...)
	/app/pkg/jira/client.go:167
github.com/ankitpokhrel/jira-cli/pkg/jira.(*Client).Me(0xc000476380)
	/app/pkg/jira/me.go:18 +0xcc
github.com/ankitpokhrel/jira-cli/internal/config.(*JiraCLIConfigGenerator).verifyLoginDetails(0xc000715cb0, {0xc00029a1b0, 0x21}, {0xc00024bb10, 0xc})
	/app/internal/config/generator.go:293 +0x20f
github.com/ankitpokhrel/jira-cli/internal/config.(*JiraCLIConfigGenerator).configureServerAndLoginDetails(0xc00055fcb0)
	/app/internal/config/generator.go:277 +0x507
github.com/ankitpokhrel/jira-cli/internal/config.(*JiraCLIConfigGenerator).Generate(0xc000715cb0)
	/app/internal/config/generator.go:117 +0x68
github.com/ankitpokhrel/jira-cli/internal/cmd/init.initialize(0xc0004c3b80, {0xcebe73, 0x2, 0x2})
	/app/internal/cmd/init/init.go:105 +0x205
github.com/spf13/cobra.(*Command).execute(0xc0004c3b80, {0xc000324420, 0x2, 0x2})
	/app/vendor/github.com/spf13/cobra/command.go:876 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc0004c3900)
	/app/vendor/github.com/spf13/cobra/command.go:990 +0x3bc
main.main()
	/app/cmd/jira/main.go:12 +0x1e

xuanyuanaosheng avatar Nov 21 '22 09:11 xuanyuanaosheng

Hi @xuanyuanaosheng, thank you for testing. I guess you are running it with --debug flag, do you get similar error if you run it without the --debug flag?

ankitpokhrel avatar Nov 22 '22 08:11 ankitpokhrel

@ankitpokhrel The new error without the --debug flag is as below

./jira init --insecure 
You are using --insecure option. In this mode, the client will NOT verify
server's certificate chain and host name in requests to the jira server.

? Installation type: Local
? Link to Jira server: https://jira.prod
? Login username: test

✗ Unable to generate configuration: x509: certificate signed by unknown authority

I think the --insecure is not work which is like https://github.com/ankitpokhrel/jira-cli/discussions/271 , Please help to add the --insecure flag.

xuanyuanaosheng avatar Nov 23 '22 02:11 xuanyuanaosheng

@ankitpokhrel Any update?

xuanyuanaosheng avatar Nov 25 '22 02:11 xuanyuanaosheng

The --insecure flag is already available in the init command. Are you sure the your jira server is using https and not http?

ankitpokhrel avatar Nov 25 '22 08:11 ankitpokhrel

@ankitpokhrel Yes, our jira server is using https.

I also tried the http,the error is

✗ Received unexpected response '301 Moved Permanently' from jira. Please try again.

xuanyuanaosheng avatar Nov 25 '22 09:11 xuanyuanaosheng

I found some discrepancy with --insecure flag and should be resolved in #507. Could you please test again using latest docker image or building it with go? Thanks

ankitpokhrel avatar Nov 26 '22 11:11 ankitpokhrel

@ankitpokhrel I am using the latest main:

# ./jira version
(Version="main", GitCommit="608fc9e3e85a232ef6f6b3f4870bea5eb5fdb208", CommitDate="2022-11-27T10:24:22+00:00", GoVersion="go1.17.11", Compiler="gc", Platform="linux/amd64")

The error is

✗ Received unexpected response '404 ' from jira. Please try again.

xuanyuanaosheng avatar Nov 28 '22 09:11 xuanyuanaosheng

The fix for making the board optional is not merged yet so main branch won't work. You need to use the branch for PR #502.

go install github.com/ankitpokhrel/jira-cli/cmd/jira@issue-464

// Or, with docker

docker pull ghcr.io/ankitpokhrel/jira-cli:issue-464

ankitpokhrel avatar Nov 28 '22 10:11 ankitpokhrel

@ankitpokhrel I test it.

The SR can not work

# ./jira init --insecure
You are using --insecure option. In this mode, the client will NOT verify
server's certificate chain and host name in requests to the jira server.

? Installation type: Local
? Link to Jira server: https://jira.prod
? Login username: test
? Default project: SR
? Default board: None

✗ Got response in unexpected format when fetching metadata. Please try again.

But the IN can work

# ./jira init --insecure
You are using --insecure option. In this mode, the client will NOT verify
server's certificate chain and host name in requests to the jira server.

? Installation type: Local
? Link to Jira server: https://jira.prod
? Login username: test
? Default project: IN
? Default board: None

✓ Configuration generated: /root/.config/.jira/.config.yml

Using IN config, The jira-cli can work fine.

Thanks

xuanyuanaosheng avatar Nov 29 '22 03:11 xuanyuanaosheng

The SR can not work

Can you provide more information about what kind of project is this?

ankitpokhrel avatar Dec 01 '22 09:12 ankitpokhrel

@ankitpokhrel

This is only for selected:

image

image


I also have tested in our test environment and select the SR project it worked. I think it is some config problem.

I asked our jira admin, he said the IN project is the same as SR project. I have no more information about this question, I will add new comment if have new find.

xuanyuanaosheng avatar Dec 07 '22 06:12 xuanyuanaosheng

Closing this as initial issue should be fixed with #502 and #507. Please feel free to open a new issue in case there are other things to check.

ankitpokhrel avatar Mar 04 '23 10:03 ankitpokhrel