Coder Social home page Coder Social logo

Comments (11)

keepcosmos avatar keepcosmos commented on May 26, 2024

Could you try jira issue ls -p?
Same error? And how many projects do you have?

from terjira.

 avatar commented on May 26, 2024

I get a response from the server

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/json/common.rb:155:in `parse': 757: unexpected token at '<html> (JSON::ParserError)

I also get a 401, and a lot of Javascript as a response

from terjira.

 avatar commented on May 26, 2024

It looks like I am running an old version of ruby, updating to 2.4.1 to see if that resolves any issues.

from terjira.

keepcosmos avatar keepcosmos commented on May 26, 2024

401 is unauthorized right? Could you try jira login again?

from terjira.

taufek avatar taufek commented on May 26, 2024

I'm getting below error stack trace

 ▲ rubydock-container/apps/terjira bin/terjira issue new
Choose project? AP - Awesome Project
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/tty-prompt-0.12.0/lib/tty/prompt/list.rb:209:in `block in validate_defaults'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/tty-prompt-0.12.0/lib/tty/prompt/list.rb:203:in `each'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/tty-prompt-0.12.0/lib/tty/prompt/list.rb:203:in `validate_defaults'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/tty-prompt-0.12.0/lib/tty/prompt/list.rb:195:in `setup_defaults'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/tty-prompt-0.12.0/lib/tty/prompt/list.rb:154:in `call'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/tty-prompt-0.12.0/lib/tty/prompt.rb:217:in `invoke_select'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/tty-prompt-0.12.0/lib/tty/prompt.rb:254:in `select'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/option_support/option_selector.rb:80:in `block in select_issuetype'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/option_support/resource_store.rb:19:in `fetch'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/option_support/option_selector.rb:9:in `fetch'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/option_support/option_selector.rb:72:in `select_issuetype'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/option_supportable.rb:67:in `block in suggest_options'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/option_supportable.rb:65:in `each'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/option_supportable.rb:65:in `suggest_options'
/Users/taufek/containers/rubydock-container/apps/terjira/lib/terjira/issue_cli.rb:62:in `new'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:115:in `invoke'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor.rb:242:in `block in subcommand'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
/Users/taufek/.asdf/installs/ruby/2.4.2/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
bin/terjira:10:in `<main>'
default index `1` out of range (1 - 0)

from terjira.

taufek avatar taufek commented on May 26, 2024

I think this is a problem in below method when the project has no issue types.

module Terjira
  module OptionSelector
    ...
    def select_issuetype
      fetch(:issuetype) do
        project = get(:issue).try(:project).try(:key)
        project ||= select_project
        if project.is_a? String
          project = Client::Project.find(project)
          set(:project, project)
        end

        # will throw an exception when project.issuetypes is empty
        option_select_prompt.select('Choose issue type?') do |menu|
          project.issuetypes.each do |issuetype|
            menu.choice issuetype.name, issuetype
          end
        end
      end
    end
    ...
  end
end

from terjira.

taufek avatar taufek commented on May 26, 2024

In Project client below it does include issueTypes in the expand query string. And issueTypes query string is correct based on JIRA doc.

require_relative 'base'

module Terjira
  module Client
    # Project Client Baseed on jira-ruby gem
    class Project < Base
      class << self
        delegate :all, :find, :fetch, to: :resource

        def all
          expand = %w(description lead issueTypes url projectKeys)
          resp = api_get 'project', expand: expand.join(',')
          resp.map { |project| build(project) }
        end

         ...
      end
    end
  end
end

But when I output the project object seems like it does not include issueTypes.

=> [#<JIRA::Resource::Project:0x00007fd616c69410
  @attrs=
   {"expand"=>"description,lead,url,projectKeys",
   "self"=>"https://jira.pbww.org:8443/rest/api/2/project/10300",
   "id"=>"10300",
   "key"=>"AP",
   "description"=>"",
   "lead"=>
    {"self"=>"https://jirahost.com/rest/api/2/user?username=system.admin",
     "key"=>"system.admin",
     "name"=>"system.admin",
     "avatarUrls"=> {...},
     "displayName"=>"System Admin",
     "active"=>true},
   "name"=>"Awesome Project",
   "avatarUrls"=> {...},
   "projectKeys"=>["AP"],
   "projectTypeKey"=>"software"},
   ...

I'm running against on-premise JIRA installation for my company. We are running JIRA Software 7.3.3. Could it be due JIRA versioning issue?

from terjira.

taufek avatar taufek commented on May 26, 2024

I tried to call the API directly using client tool (insomnia), seems like the response does include issueTypes.

Request:
GET https://jira.pbww.org:8443/rest/api/2/project/10300

Response:
{
	"expand": "description,lead,url,projectKeys",
	"self": "https://jirahost.com/rest/api/2/project/10300",
	"id": "10300",
	"key": "AP",
	"description": "",
	"lead": {
		"self": "https://jirahost.com/rest/api/2/user?username=system.admin",
		"key": "system.admin",
		"name": "system.admin",
		"avatarUrls": {
			...
		},
		"displayName": "System Admin",
		"active": true
	},
	"components": [],
	"issueTypes": [
		{
			"self": "https://jirahost.com/rest/api/2/issuetype/10002",
			"id": "10002",
			"description": "A task that needs to be done.",
			"iconUrl": "https://jirahost.com/secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype",
			"name": "Task",
			"subtask": false,
			"avatarId": 10318
		},
		{
			"self": "https://jirahost.com/rest/api/2/issuetype/10003",
			"id": "10003",
			"description": "The sub-task of the issue",
			"iconUrl": "https://jirahost.com/secure/viewavatar?size=xsmall&avatarId=10316&avatarType=issuetype",
			"name": "Sub-task",
			"subtask": true,
			"avatarId": 10316
		},
		{
			"self": "https://jirahost.com/rest/api/2/issuetype/10001",
			"id": "10001",
			"description": "gh.issue.story.desc",
			"iconUrl": "https://jirahost.com/images/icons/issuetypes/story.svg",
			"name": "Story",
			"subtask": false
		},
		{
			"self": "https://jirahost.com/rest/api/2/issuetype/10004",
			"id": "10004",
			"description": "A problem which impairs or prevents the functions of the product.",
			"iconUrl": "https://jirahost.com/secure/viewavatar?size=xsmall&avatarId=10303&avatarType=issuetype",
			"name": "Bug",
			"subtask": false,
			"avatarId": 10303
		},
		{
			"self": "https://jirahost.com/rest/api/2/issuetype/10000",
			"id": "10000",
			"description": "gh.issue.epic.desc",
			"iconUrl": "https://jirahost.com/images/icons/issuetypes/epic.svg",
			"name": "Epic",
			"subtask": false
		}
	],
	"assigneeType": "UNASSIGNED",
	"versions": [
		...
	],
	"name": "Awesome Project",
	"roles": {
		...
	},
	"avatarUrls": {
		...
	},
	"projectTypeKey": "software"
}

I'm not sure why yet when calling the rest api via ruby library it does not return issue types but when calling the rest api via api client tool it does return the issue types.

from terjira.

taufek avatar taufek commented on May 26, 2024

I think I found out the root cause. The difference between the ruby api call and the api client tool, is
in ruby api call we are calling list of projects, but with api client tool I'm calling individual project.

So when I'm calling list of project via api client tool it return list of projects without issue types.

[
	{
		"expand": "description,lead,url,projectKeys",
		"self": "https://jirahost.com/rest/api/2/project/10300",
		"id": "10300",
		"key": "AP",
		"name": "Awesome Project",
		"avatarUrls": {
			...
		},
		"projectTypeKey": "software"
	},
	{
		"expand": "description,lead,url,projectKeys",
		"self": "https://jirahost.com/rest/api/2/project/10138",
		"id": "10138",
		"key": "AAP",
		"name": "Another Awesome Project",
		"avatarUrls": {
			...
		},
		"projectTypeKey": "software"
	},
        ...

from terjira.

taufek avatar taufek commented on May 26, 2024

I've created a bug fix in #60.

from terjira.

keepcosmos avatar keepcosmos commented on May 26, 2024

Thanks @taufek

from terjira.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.