hubot-archive / hubot-auth

Assign roles to users and restrict command access in other scripts
149 stars 54 forks source link

User does not exist #51

Closed asanra001c closed 7 years ago

asanra001c commented 7 years ago

I am having issue getting this to work. I keep getting "\<username> does not exist" message back when I run "\<username> has \<role> role".

hubot version: 2.19.0 hubot-auth version: 2.0.0 hubot-redis-brain version: 0.0.3 hubot-slack version: 4.3.0

Any help is appreciated.

Thanks

Here's my log:

[Sun Jan 15 2017 04:21:34 GMT+0000 (UTC)] DEBUG Loading adapter slack
[Sun Jan 15 2017 04:21:38 GMT+0000 (UTC)] INFO Logged in as angelo_sanramon_hubot of t+p
[Sun Jan 15 2017 04:21:38 GMT+0000 (UTC)] INFO Slack client now connected
[Sun Jan 15 2017 04:21:38 GMT+0000 (UTC)] DEBUG Loading scripts from /home/asanra001c/myhubot/scripts
[Sun Jan 15 2017 04:21:38 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/scripts/example.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/scripts/route53-healthchecks.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/scripts/x1sports_service.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Loading scripts from /home/asanra001c/myhubot/src/scripts
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Loading external-scripts from npm packages
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-diagnostics/src/diagnostics.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-help/src/help.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-google-images/src/google-images.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-google-translate/src/google-translate.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-pugme/src/pugme.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-maps/src/maps.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-redis-brain/src/redis-brain.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-rules/src/rules.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-shipit/src/shipit.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-reload-scripts/src/reload-scripts.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-auth/src/auth.coffee
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] DEBUG hubot-redis-brain: Successfully connected to Redis
[Sun Jan 15 2017 04:21:39 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Sun Jan 15 2017 04:22:33 GMT+0000 (UTC)] DEBUG Received message: 'angelo_sanramon_hubot angelo_sanramon has support role' in channel: DM, from: angelo_sanramon
[Sun Jan 15 2017 04:22:33 GMT+0000 (UTC)] DEBUG Message 'angelo_sanramon_hubot angelo_sanramon has support role' matched regex //^\s*[@]?angelo_sanramon_hubot[:,]?\s*(?:@?([^\s]+) ha(?:s|ve) (["'\w: -_]+) role)/i/; listener.options = { id: null }
[Sun Jan 15 2017 04:22:33 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'angelo_sanramon_hubot angelo_sanramon has support role'
[Sun Jan 15 2017 04:22:33 GMT+0000 (UTC)] DEBUG Sending to D3K5FJS7Q: angelo_sanramon does not exist
[Sun Jan 15 2017 04:22:33 GMT+0000 (UTC)] DEBUG Sending to D3K5FJS7Q: angelo_sanramon does not exist
sebastiandero commented 7 years ago

Hey weird thing thats happening there, DEBUG Executing listener callback for Message 'angelo_sanramon_hubot angelo_sanramon has support role should be your callback. I will test it myself give me a second

sebastiandero commented 7 years ago

@asanra001c

image

Everything looks splendid for me :/

I suggest clean installing the whole bot from scratch, or atleast wiping your redis-brain

asanra001c commented 7 years ago

@sebastiandero thanks for the reply. I'll try reinstalling hubot and try it again. Also, I get "Can't fetch users" error message. Does my slack bot needs to have some special permission to read users list?

Thanks

sebastiandero commented 7 years ago

@asanra001c No special permission are needed, the slack api provides everything it needs I will check if the slack adapter is spitting out that error

sebastiandero commented 7 years ago

@asanra001c yup the message is comming from hubot-slack src/bot.coffee

maybe try adding a @robot.logger.error "User loading error: "+err in the file <botdir>/node_modules/hubot-slack/src/bot.coffee in loadingUsers() that would give you some more information

asanra001c commented 7 years ago

@sebastiandero ok, I will do that.

Thanks

sebastiandero commented 7 years ago

@asanra001c let me know how it goes

asanra001c commented 7 years ago

@sebastiandero I generated a new hubot instance. Here's a new log when I ran the user has role command again.

[Mon Jan 16 2017 05:04:57 GMT+0000 (UTC)] DEBUG Loading adapter slack
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] INFO Logged in as angelo_sanramon_hubot of t+p
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] INFO Slack client now connected
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Loading scripts from /home/asanra001c/myhubot/scripts
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/scripts/example.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Loading scripts from /home/asanra001c/myhubot/src/scripts
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Loading hubot-scripts from /home/asanra001c/myhubot/node_modules/hubot-scripts/src/scripts
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.

Your hubot-scripts.json is empty, so you just need to remove it.
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Loading external-scripts from npm packages
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-diagnostics/src/diagnostics.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-help/src/help.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-google-images/src/google-images.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-google-translate/src/google-translate.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-pugme/src/pugme.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-maps/src/maps.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-redis-brain/src/redis-brain.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-rules/src/rules.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-shipit/src/shipit.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG Parsing help for /home/asanra001c/myhubot/node_modules/hubot-auth/src/auth.coffee
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] DEBUG hubot-redis-brain: Successfully connected to Redis
[Mon Jan 16 2017 05:05:02 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Mon Jan 16 2017 05:05:38 GMT+0000 (UTC)] DEBUG Received message: 'angelo_sanramon_hubot angelo_sanramon has support role' in channel: DM, from: angelo_sanramon
[Mon Jan 16 2017 05:05:38 GMT+0000 (UTC)] DEBUG Message 'angelo_sanramon_hubot angelo_sanramon has support role' matched regex //^\s*[@]?angelo_sanramon_hubot[:,]?\s*(?:@?([^\s]+) ha(?:s|ve) (["'\w: -_]+) role)/i/; listener.options = { id: null }
[Mon Jan 16 2017 05:05:38 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'angelo_sanramon_hubot angelo_sanramon has support role'
[Mon Jan 16 2017 05:05:38 GMT+0000 (UTC)] DEBUG Sending to D3K5FJS7Q: angelo_sanramon does not exist
[Mon Jan 16 2017 05:05:38 GMT+0000 (UTC)] DEBUG Sending to D3K5FJS7Q: angelo_sanramon does not exist
[Mon Jan 16 2017 05:10:08 GMT+0000 (UTC)] ERROR Can't fetch users: Error: Unable to process request, received bad 500 error
asanra001c commented 7 years ago

Closing issue. Not a hubot-auth issue. It's probably an issue with slack.

xmakina commented 7 years ago

I think this needs to be re-opened as it is an issue with hubot-auth

The hubot brain returns null if the user is not found in the brain https://github.com/github/hubot/blob/master/src/brain.coffee#L118 hubot-auth returns user not found if robot.brain.userForName is null https://github.com/hubot-scripts/hubot-auth/blob/master/src/auth.coffee#L83

There is no method I can see to add users to the brain.

Has confusion occured because userForId will add a user if one isn't found, whilst userForName will not?