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

mergeData in 2.19.0 overwriting brain roles set by HUBOT_AUTH_ROLES #1219

Closed
twellspring opened this issue Jul 29, 2016 · 2 comments
Closed
Labels

Comments

@twellspring
Copy link

Roles set by HUBOT_AUTH_ROLES is being overwritten by robot.brain.mergeData.
Possibly same issue as #846

Using

hubot 2.19.0
hubot-auth 1.3.0
hubot-redis-brain 0.0.3

I have my ID in the environment variable
HUBOT_AUTH_ROLES="admin=xxxxxxxx staging=xxxxxxxx"

In hubot-auth/src/auth.coffee after line 56 I added lines to show my roles.

          user.roles.push roleName unless roleName in user.roles
          user2 = robot.brain.userForName('toddwells')
          robot.logger.info "ROLES-AUTH: #{JSON.stringify(user2.roles)}"

in hubot-redis-brain/src/redis-brain.coffee at line 48 I added the same before and after the redis merge

        user2 = robot.brain.userForName('toddwells')
        robot.logger.info "ROLES-REDIS-PRE: #{JSON.stringify(user2.roles)}"

        robot.logger.info "hubot-redis-brain: Data for #{prefix} brain retrieved from Redis"
        robot.brain.mergeData JSON.parse(reply.toString())

        user2 = robot.brain.userForName('toddwells')
        robot.logger.info "ROLES-REDIS-POST: #{JSON.stringify(user2.roles)}"

The results show that I have the expected roles before the merge but not after

[Fri Jul 29 2016 15:37:46 GMT+0000 (UTC)] INFO Connecting...
[Fri Jul 29 2016 15:37:47 GMT+0000 (UTC)] INFO Logged in as xxxxx of xxxxxxxx, but not yet connected
[Fri Jul 29 2016 15:37:47 GMT+0000 (UTC)] INFO Slack client now connected
[Fri Jul 29 2016 15:37:48 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.
[Fri Jul 29 2016 15:37:48 GMT+0000 (UTC)] INFO ROLES-AUTH: ["admin","staging"]
[Fri Jul 29 2016 15:37:48 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Fri Jul 29 2016 15:37:48 GMT+0000 (UTC)] INFO ROLES-REDIS-PRE: ["admin","staging"]
[Fri Jul 29 2016 15:37:48 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Fri Jul 29 2016 15:37:48 GMT+0000 (UTC)] INFO ROLES-REDIS-POST: undefined
@alekzonder
Copy link

@twellspring may be use here lodash.merge package ?

https://www.npmjs.com/package/lodash.merge

@stale
Copy link

stale bot commented May 30, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants