Skip to content

Conversation

@srhmgn
Copy link
Contributor

@srhmgn srhmgn commented Sep 12, 2022

Using the library, I noticed I was not getting an error in the scenario where I was using the client with a missing or incorrect token:

  const jira = new Jira({
      protocol: "https",
      host: "jira.somehost.com",
      username: "valid@username.com",
      password: "invalid-token",
  });

const res = await jira.searchJira('project = COOLPROJECT');

Instead of throwing an error, res is the string "Basic authentication with passwords is deprecated. For more information, see: https://developer.atlassian.com/cloud/confluence/deprecation-notice-basic-auth/"

This PR updates the logic in the doRequest and request functions to throw an error if:

  • postman-request fails with an error
  • request has a status code in the 400s or 500s

I used a tool called rewire to mock postman-request for testing and updated some related tests to use rewire as well.

@srhmgn srhmgn force-pushed the request-error-handling branch 2 times, most recently from 480d4ff to 93ea5f9 Compare September 12, 2022 14:40
@srhmgn srhmgn force-pushed the request-error-handling branch from 93ea5f9 to fcd0802 Compare September 12, 2022 14:41
@mtscout6 mtscout6 self-requested a review October 1, 2022 15:23
@mtscout6 mtscout6 merged commit 9dc7c18 into jira-node:master Oct 1, 2022
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

Successfully merging this pull request may close these issues.

3 participants