Skip to content
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

"jira list ..." encounters "ERROR Invalid Usage: invalid character '<' looking for beginning of value" #477

Open
thearifismail opened this issue Dec 13, 2022 · 5 comments

Comments

@thearifismail
Copy link

thearifismail commented Dec 13, 2022

I am trying to write some go code to fetch JIRA issues from our internal JIRA deployment. No such problem is encountered when using Python. I am very new to "GO" and thinking running Jira query should provide an easy ramp. Hopefully someone can spot the mistake I am making.

The error is the same when I did the following. The actual project name has been replaced by <PROJECT_NAME> in this submission:

  1. Built JIRA locally by cloning this repo
  2. Downloaded a pre-built binary from release web page
  3. Used jira custom command, like jira search
  4. jira list --query="project=<PROJECT_NAME> AND resolution = Unresolved AND assignee = currentUser()"
  5. jira list --query="resolution+=+Unresolved+AND+assignee+=+currentUser()" . This query was provided by Firefox's "Web Developer Tools"
  6. jira list --template table --query="project=<PROJECT_NAME> AND resolution = Unresolved AND assignee = currentUser()"

The project name is specified in ~/.jira.d/config.yml and using JIRA_API_TOKEN because of authentication-method: api-token.

Here is ~/.jira.d/config.yml:

endpoint: https://issues.redhat.com/
user: [email protected]
authentication-method: api-token
project: <PROJECT_NAME>
custom-commands:
  - name: print-project
    help: print the JIRA environment variables available to custom commands
    script: |
      echo $JIRA_PROJECT
  - name: search
    help: list bugs based on the query provided 
    script: |
      {{jira}} list --template table --query="resolution+=+Unresolved+AND+assignee+=+currentUser()" 

Here is the full console output for the commands provided above:

$ jira list --template table --query="resolution = Unresolved AND assignee = currentUser()"
usage: jira list [<flags>]
alias: jira ls [<flags>]

Prints list of issues for given search criteria

Global flags:
  -h, --help                   Show context-sensitive help (also try --help-long and --help-man).
  -v, --verbose ...            Increase verbosity for debugging
  -e, --endpoint=ENDPOINT      Base URI to use for Jira
  -k, --insecure               Disable TLS certificate verification
  -Q, --quiet                  Suppress output to console
      --unixproxy=UNIXPROXY    Path for a unix-socket proxy
      --socksproxy=SOCKSPROXY  Address for a socks proxy
  -u, --user=USER              user name used within the Jira service
      --login=LOGIN            login name that corresponds to the user used for authentication

Optional flags:
  -t, --template=TEMPLATE        Template to use for output
      --gjq=GJQ                  GJSON Query to filter output, see https://goo.gl/iaYwJ5
  -a, --assignee=ASSIGNEE        User assigned the issue
  -c, --component=COMPONENT      Component to search for
  -i, --issuetype=ISSUETYPE      Issue type to search for
  -l, --limit=LIMIT              Maximum number of results to return in search
  -p, --project=PROJECT          Project to search for
  -n, --named-query=NAMED-QUERY  The name of a query in the `queries` configuration
  -q, --query=QUERY              Jira Query Language (JQL) expression for the search
  -f, --queryfields=QUERYFIELDS  Fields that are used in "list" template
  -r, --reporter=REPORTER        Reporter to search for
  -S, --status=STATUS            Filter on issue status
  -s, --sort=SORT                Sort order to return
  -w, --watcher=WATCHER          Watcher to search for

ERROR Invalid Usage: invalid character '<' looking for beginning of value
$
@thearifismail
Copy link
Author

I tried to follow the information provided in issue #250 but no success yet.

@thearifismail
Copy link
Author

This problem is authentication failure, which is very likely is being caused by mixup of how user, username, login, password, and/ or api-token should be used.

@k-wall
Copy link

k-wall commented Jan 12, 2023

I hit this myself yesterday. Add three --verbose arguments into the command line so you see the HTTP interactions. You'll be seeing a HTML unauthorised response probably like this:

<html>

<head>
    <title>Unauthorized (401)</title>

The invalid character '<' looking for beginning of value is it choking in the HTML stream.

I'm successfully using PAT tokens (authentication-method: bearer-token) with issues.redhat.com but I needed to build from source (main) to pick up changes that include the support.

HTH

@nicballarini
Copy link

nicballarini commented Nov 1, 2024

I hit this myself yesterday. Add three --verbose arguments into the command line so you see the HTTP interactions. You'll be seeing a HTML unauthorised response probably like this:

<html>

<head>
    <title>Unauthorized (401)</title>

The invalid character '<' looking for beginning of value is it choking in the HTML stream.

I'm successfully using PAT tokens (authentication-method: bearer-token) with issues.redhat.com but I needed to build from source (main) to pick up changes that include the support.

HTH

Could you expand on the process you used for bearer-token auth?

@k-wall
Copy link

k-wall commented Nov 11, 2024

Could you expand on the process you used for bearer-token auth?

I've stopped using the tool. However, my config (which IIRC was working):

endpoint: https://issues.redhat.com

# This is compatible with Jira Personal Access Tokens (PATs)
authentication-method: bearer-token
password-source: keyring

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

No branches or pull requests

3 participants