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

Oauth URL broken and runtime error with logErrorInstance #460

Merged
merged 4 commits into from
Mar 31, 2021

Conversation

miketalley
Copy link
Contributor

Description and Context

  • buildAuthUrl was not obtaining the correct accountId because it was looking for portalId instead this resulted in undefined being used in the URL instead of the portalId
  • The import of logErrorInstance was wrong and causing a runtime error
[ERROR] A TypeError has occurred. logErrorInstance is not a function
[DEBUG] Error: TypeError: logErrorInstance is not a function
    at addOauthToAccountConfig (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli-lib/oauth.js:50:5)
    at authenticateWithOauth (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli/lib/oauth.js:98:3)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async Object.oauthConfigCreationFlow [as oauth2] (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli/commands/init.js:58:3)
    at async Object.exports.handler (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli/commands/init.js:108:27) {
  [stack]: 'TypeError: logErrorInstance is not a function\n' +
    '    at addOauthToAccountConfig (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli-lib/oauth.js:50:5)\n' +
    '    at authenticateWithOauth (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli/lib/oauth.js:98:3)\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:94:5)\n' +
    '    at async Object.oauthConfigCreationFlow [as oauth2] (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli/commands/init.js:58:3)\n' +
    '    at async Object.exports.handler (/Users/mtalley/.config/yarn/global/node_modules/@hubspot/cli/commands/init.js:108:27)',
  [message]: 'logErrorInstance is not a function'

Who to Notify

@alnoorp

@@ -95,7 +95,7 @@ const authenticateWithOauth = async configData => {
const oauthManager = setupOauth(accountId, configData);
logger.log('Authorizing');
await authorize(oauthManager);
addOauthToAccountConfig(accountId, oauthManager);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still be doing the portalId parse on line 94?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Yeah we still need to do that. I moved it into setupOauth because that is where it's needed and it doesn't make sense to do the parsing in authenticateWithOauth anymore.

@brandenrodgers
Copy link
Contributor

Code lgtm 👍

When running hs init locally, I noticed we still have this issue [SUCCESS] The config file "/Users/brodgers/src/cms-devex-super-repo/hubspot-cli/hubspot.config.yml" was created using your personal access key for account undefined. Is this undefined related to the portalId vs. accountId thing?

@miketalley
Copy link
Contributor Author

miketalley commented Mar 31, 2021

Code lgtm 👍

When running hs init locally, I noticed we still have this issue [SUCCESS] The config file "/Users/brodgers/src/cms-devex-super-repo/hubspot-cli/hubspot.config.yml" was created using your personal access key for account undefined. Is this undefined related to the portalId vs. accountId thing?

Ah yes, that is a separate issue that I have a fix for in another branch. I'll pull that into this branch as it is related.

Edit: This has now been fixed in this branch.

@gcorne
Copy link
Contributor

gcorne commented Mar 31, 2021

It would be good to have some test coverage if there is time since this is not the most common code path now that personal access keys are the recommended auth flow.

@miketalley
Copy link
Contributor Author

miketalley commented Mar 31, 2021

It would be good to have some test coverage if there is time since this is not the most common code path now that personal access keys are the recommended auth flow.

Thank you for mentioning this! I actually brought this up in a meeting yesterday and didn't add it. I'll work on adding this.

Edit: Looking at adding this in a separate PR to the tests repo https://github.com/HubSpot/hubspot-cli-tests. Do we want to eventually move the tests into this repo?

@miketalley
Copy link
Contributor Author

I'm going to merge this to unblock @alnoorp and add the tests async.

@miketalley miketalley merged commit 0cb8795 into master Mar 31, 2021
@miketalley miketalley deleted the hotfix/oauth-url-fix branch March 31, 2021 21:31
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.

4 participants