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

jira init not able to read the .netrc file

Open rbhanot4739 opened this issue 10 months ago • 7 comments

Describe the bug

After creating the ~/.netrc file with the following contents, when I run jira init it fails with 401.

machine <jira local server>
login <rbhanot>
password <token>

Please provide following details

  1. JiraCLI Version:
    (Version="1.5.2", GitCommit="refs/tags/v1.5.2", CommitDate="1970-01-01T00:00:00+00:00", GoVersion="go1.23.4", Compiler="gc", Platform="darwin/arm64")
    
    
  2. Are you using Jira cloud or on-premise jira server?
    Jira on premise server
    
  3. What operating system are you using? Also mention version.
    macOs 15.2 
    
  4. What terminal are you using? Also mention version.
    Wezterm
    

To Reproduce

Steps to reproduce the behavior:

  1. Create ~/.netrc file with contents as suggested here
  2. Run jira init
❯ jira init
? Installation type: Local
? Authentication type: bearer
? Link to Jira server: <https://jira01.....>
? Login username: <username>

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

Expected behavior The jira init should be able to read the config from ~/.netrc.

rbhanot4739 avatar Jan 15 '25 13:01 rbhanot4739

This actually looks like an issue with init command. Are you able to use .netrc after generating the config?

ankitpokhrel avatar Jan 16 '25 17:01 ankitpokhrel

Nope... the config generation isn't even completing because init is failing,..

rbhanot4739 avatar Jan 16 '25 18:01 rbhanot4739

I meant if you can generate config using other methods (eg: setting JIRA_API_TOKEN) and then try to use .netrc, does it seem to work?

ankitpokhrel avatar Jan 16 '25 20:01 ankitpokhrel

So if I run jira init with api token, it completes and config is generated. However if I open a new shell where the environment var is not set, jira issue list or any other fetching commands for that matter fails even if there is .netrc.

rbhanot4739 avatar Jan 17 '25 14:01 rbhanot4739

Bumping this. I cannot store the API token in my .zshrc since the config is shared and this key needs to stay local.

Currently does not work with .netrc in any capacity

jacksonSingleton avatar Feb 20 '25 15:02 jacksonSingleton

@jacksonSingleton I agree, storing token in zshrc isn't even a good idea since its a token its suppose to be stored securely. A .netrc is the right place for it but apparantly it isn't working.

rbhanot4739 avatar Feb 20 '25 15:02 rbhanot4739

@ankitpokhrel Is there an eta on this, It kinda makes the tool unusable for me at the moment.

rbhanot4739 avatar Mar 06 '25 15:03 rbhanot4739

@ankitpokhrel Any plans to fix this bug? For someone who version controls his dotfiles, I can't keep the Jira API token in shell rc files.

@jacksonSingleton Not sure if you found a workaround to this but I ended up creating a function in zsh functions directory and then autoloading it at shell startup.

~/zsh-functions/set_token

_set_jira_token() {
  export JIRA_API_TOKEN=$(rg password ~/.netrc | awk '{print $2}')
  return 0
}

.zshrc snippet

CUSTOM_COMPLETION_DIR=($HOME/zsh_completions $zsh_functions)
typeset -U fpath=($CUSTOM_COMPLETION_DIR $fpath)

# Autoload all functions from zsh_functions directory
for func in $HOME/zsh_functions/*(.N:t); do
  autoload -Uz $func
done

And then finally on shell startup I just do set_token and the token is set now.

rbhanot4739 avatar Jun 19 '25 07:06 rbhanot4739

The same story on Windows. In addition it's very strange that settings are stored in the special directory and file $HOME/.config/.jira/.config.yml but credentials can't be stored. And no integration with credentials manager at all

QuAzI avatar Jul 19 '25 15:07 QuAzI