gsingers / slack-jira-plugin

A Slack plugin that watches channels for messages about JIRA and acts accordingly
MIT License
252 stars 83 forks source link

Server returning Invalid issue number, although the number is valid #18

Open mirgee opened 8 years ago

mirgee commented 8 years ago

Hi, I get the bot to correctly find the project name, and login to the Jira server, however, it returns Invalid issue number message, altough the issue number is correct. I believe everything in the config file is setup properly, so I think the culprit is in the API call, maybe there is a bug in the way the plugin formats the API call. I would like to ask - how does the plugin format the API call? E.g. the string "MOB-27579" is mentioned, the message "MOB-27579 - ​Invalid issue number." is returned. Shouldn't the number be just "27579"? Thank you!

Here is my config file, can you please take a look? Does it seem OK? Thank you!

var slackbot = require('./lib/bot');

var config = {

  showIssueDetails: true,
  issueDetailsToShow: {'fields.summary':1 , 'fields.assignee' : 1, 'fields.creator' : 0, 'fields.description': 0},
  showDetailsByDefault: true,
  bot_name: "jira",
  token: '<token>',
  jira_urls: {
    // DEFAULT NODE IS REQUIRED.
    "DEFAULT": {url: "https://jira.concur.com/jira/browse/"},
    // These should match projects from the projects property where you want to use a configuration other than the default
    "MOB": {
      url: "https://jira.concur.com/jira/browse/",
      jira: {
        user: 'MiroslavK', // be sure to use the username, not the user email
        password: '<password>',
        host: 'jira.concur.com',
        protocol: 'https',
        port: 443,
        version: '2',
        verbose: true,
        strictSSL: true
      }
    },
  },
  search_cmd: "search",
  //Since search results can be verbose, you may not want to muddy the channel
  search_output_chan: "this",//if the value is "this", then the current channel will be used, else the name of a channel
  projects: ["MOB"],
  post: true,
  verbose: true,
  custom_texts: {
    messagePrefix: "Hey, thought this might help: " //message you might like to prefix to JiraBot's post
  },
  emoji: ":jira:", // be sure to upload your custom emoji in slack
  link_separator: ", ",// use \n if you want new lines
  error_channel: '' //the id of the channel to send low level log errors.  If not defined, will use the current channel
};

//DO NOT EDIT BELOW HERE
var slackbot = new slackbot.Bot(config);
slackbot.run();
gsingers commented 8 years ago

Hmm, you might be hitting a bug in the underlying JIRA library itself in that it doesn't handle paths on the URL correctly right now. I think there is a patch for the library, but I haven't tried it myself yet.

vbouchet31 commented 8 years ago

Just my 2 cent insight. I had the same error. I searched for the string "Invalid issue number" in the jira.js library. Before the dorequest method, I added the callback(options.uri); line to check which url was used to do the request.

Based on your current configuration, the url may be https://jira.concur.com:443/rest/api/2/issue/MOB-27579 but you probably want to target https://jira.concur.com:443/jira/rest/api/2/issue/MOB-27579 (try it in a browser).

To do so, I used the port as a workaround: port: '443/jira

and voila, it worked.

Hope it helps.