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

TypeError being thrown #12

Closed
tomholland opened this issue Jun 2, 2016 · 9 comments
Closed

TypeError being thrown #12

tomholland opened this issue Jun 2, 2016 · 9 comments

Comments

@tomholland
Copy link
Contributor

tomholland commented Jun 2, 2016

TypeError: Cannot match against &#39;undefined&#39; or &#39;null&#39;.<br> &nbsp; &nbsp;at getFileContents (/usr/src/app/src/utils.js:101:65)<br> &nbsp; &nbsp;at storage.forEach (/usr/src/app/src/server.js:63:21)<br> &nbsp; &nbsp;at Object.<anonymous> (/usr/src/app/node_modules/node-persist/src/local-storage.js:178:13)<br> &nbsp; &nbsp;at Array.forEach (native)<br> &nbsp; &nbsp;at Object.LocalStorage.forEach (/usr/src/app/node_modules/node-persist/src/local-storage.js:177:28)<br> &nbsp; &nbsp;at Object.nodePersist.forEach (/usr/src/app/node_modules/node-persist/src/node-persist.js:73:29)<br> &nbsp; &nbsp;at app.route.get.post (/usr/src/app/src/server.js:57:21)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/usr/src/app/node_modules/express/lib/router/route.js:131:13)<br> &nbsp; &nbsp;at /usr/src/app/node_modules/body-parser/lib/read.js:129:5

(the bot is being hosted on beepboop)

@okonet
Copy link
Contributor

okonet commented Jun 2, 2016

Where are you seeing this error and what did you do to get it?

@tomholland
Copy link
Contributor Author

tomholland commented Jun 2, 2016

When I type

/code <beanstalk file url>

in a Slack channel the bot is added to, that is what the bot says back.

To get the URL, I'm clicking on a line of code in the web UI and copying the resulting URL:

https://<subdomain>.beanstalkapp.com/<repo_name>/browse/trunk/file.ext?ref=c-<revision-no>

I've tried clicking on the line number instead, so it appends

#L<[0-9]+>

to the end of the URL - but I get the same result.

This is based on what the bot responds with when I asked it for 'help':

How to get started

  1. Browse to a specific file in one of your Beanstalk repositories
  2. In Beanstalk, click on the line of code you want to share
  3. Copy the URL from your browser and paste it into slack

Am I just using the wrong URLs? (if so - maybe the bot could check for that, and tell me what I should be doing instead?)

@okonet
Copy link
Contributor

okonet commented Jun 2, 2016

I was able to fix the issue but may I know the URL you're using instead of <beanstalk file url> so I can add some more tests to the code?

@okonet okonet closed this as completed in 9089501 Jun 2, 2016
@okonet
Copy link
Contributor

okonet commented Jun 2, 2016

The bug fix should be up and running. Can you please check if it solves it?

@tomholland
Copy link
Contributor Author

tomholland commented Jun 2, 2016

All I get now is "We had an issue getting the snippet from Beanstalk. Please make sure that you entered the correct username and authorization token." instead of the error output.

Just to confirm a few things.

In the Beep Boop config screen, it asks for Beanstalk username and "Auth Token" - but I'm using API Access tokens, that I'm creating in my account; is that not correct? Does the app not verify these credentials before first trying to use them? (i.e. on save?)

The other part that is somewhat strange is that Beanstalk usernames are only unique within account subdomains(?); does the token mean there is need to account for this?

Can you give an example of the file URL format the app is expecting?

And has this been tested with Subversion as well as Git repositories, btw?

@okonet
Copy link
Contributor

okonet commented Jun 2, 2016

  1. Yes, "Auth token" is the API token. We recommend creating a special "bot" user in your account and give that user read-only access. Then generate an API token for this user and use it in the BeepBoop screen.
  2. We don't validate the credentials at the moment. That's a good point and we will probably will add it. I'll add a separate issue for it.
  3. Yes, you'll need a user/token for each of your accounts. I'm not sure you can add several bots to your Slack team. At the moment our Bot supports only one Beanstalk per bot and if this is a case, we might want to extend it as well.
  4. The bot expects an URL you'll see when browsing files (/browse). Something like this: https://<account>.beanstalkapp.com/<repository>]/browse/git/<filename>
  5. We don't use Subversion anymore but it should work as well since the bot is using the API that's VCS independent AFAIK.

@tomholland
Copy link
Contributor Author

Ok - figured it out: I don't get the credentials error when I try and reference a file in a Git repository - only Subversion repositories. Beanstalk still offer both (I prefer Git, but still have to work with Subversion ones sometimes).

If it needs special attention to work with Subversion (and it's not something you want to look into, because you don't use Subversion repositories any more), it might be worth highlighting it's Git repositories only in the README.md file / help docs (saves other Subversion users the time figuring that out / pestering you with duplicate issues).

You might be able to detect if it's not a Git repo and give a Subversion unsupported warning? My Git repo file URLs seem to start with this:

https://<subdomain>.beanstalkapp.com/<repo_name>/browse/git/

(my project doesn't have a 'git' directory at root level! - so I presume this is something generic on Beanstalk's side)

…whereas, my Subversion URLs start like like this:

https://<subdomain>.beanstalkapp.com/<repo_name>/browse/trunk https://<subdomain>.beanstalkapp.com/<repo_name>/browse/tags https://<subdomain>.beanstalkapp.com/<repo_name>/browse/branches

(I don't think you could rely on solely on 'trunk', 'tags' or 'branches' being the only ones that might be present for a Subversion repository - since I believe they are just directories, so you could add your own at the root level [although it's not the standard approach]; however, maybe the 3rd [index 2] path component not being 'git' would be a good indicator that it's a Subversion repo - and the bot can give a specific response about not reporting Subversion repositories?)

@tomholland
Copy link
Contributor Author

tomholland commented Jun 2, 2016

Oh, and I know it's minor; but on your item 1 - it is possible to amend the label from "Auth token" to "API Access token" in the Beep Boop config screen? I'd assumed that was what it meant - but the terminology is different enough (especially if you've worked with OAuth before) to make one wonder if you are using the right kind of credential ;) (especially if the bot is responding saying "Please make sure that you entered the correct username and authorization token"; I did review the Beanstalk API docs, to make sure I wasn't missing something about different credential types...)

@okonet
Copy link
Contributor

okonet commented Jun 2, 2016

Very good points!

We'll look into subversion issues soon. I've created separate issues for these.

See #15, #16

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

2 participants