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

Slack import failed : TypeError: Cannot read property 'toUpperCase' of undefined #4614

Closed
lc3t35 opened this issue Oct 12, 2016 · 3 comments · Fixed by #4615
Closed

Slack import failed : TypeError: Cannot read property 'toUpperCase' of undefined #4614

lc3t35 opened this issue Oct 12, 2016 · 3 comments · Fixed by #4615

Comments

@lc3t35
Copy link

lc3t35 commented Oct 12, 2016

Your Rocket.Chat version: 0.43.0-develop (with PR#4604)
When I import a Slack zip, it fails with this error :

Exception in defer callback: TypeError: Cannot read property 'toUpperCase' of undefined
I20161012-23:06:00.611(2)?     at [object Object].<anonymous> (packages/rocketchat_importer-slack/server.coffee:126:119)
I20161012-23:06:00.611(2)?     at packages/dispatch_run-as-user/packages/dispatch_run-as-user.js:186:1
I20161012-23:06:00.611(2)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20161012-23:06:00.611(2)?     at Object.Meteor.runAsUser (packages/dispatch_run-as-user/packages/dispatch_run-as-user.js:185:1)
I20161012-23:06:00.612(2)?     at packages/rocketchat_importer-slack/server.coffee:113:13
I20161012-23:06:00.612(2)?     at packages/rocketchat_importer-slack/server.coffee:112:5
I20161012-23:06:00.613(2)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20161012-23:06:00.613(2)?     at packages/meteor/timers.js:6:1
I20161012-23:06:00.614(2)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)

At line 126 of server.coffee, there is no control that user.profile.email is not empty

userId = Accounts.createUser { email: user.profile.email, password: Date.now() + user.name + user.profile.email.toUpperCase() }

When I look at first user.profile from imported Slack data, it does not indeed have email set :(
I verified users.json, no email in all profile fields, example for mine

"profile": {
            "skype": "lc3t35",
            "first_name": "laurent",
            "last_name": "roger",
            "fields": {
                "Xf0DAKBW9J": {
                    "value": "lc3t35",
                    "alt": ""
                }
            },
            "avatar_hash": "gcc890e21b65",
            "real_name": "laurent roger",
            "real_name_normalized": "laurent roger",
            "image_24": "https:\/\/secure.gravatar.com\/avatar\/cc890e21b652d07da9edf3edeae59188.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0008-24.png",
            "image_32": "https:\/\/secure.gravatar.com\/avatar\/cc890e21b652d07da9edf3edeae59188.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0008-32.png",
            "image_48": "https:\/\/secure.gravatar.com\/avatar\/cc890e21b652d07da9edf3edeae59188.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0008-48.png",
            "image_72": "https:\/\/secure.gravatar.com\/avatar\/cc890e21b652d07da9edf3edeae59188.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0008-72.png",
            "image_192": "https:\/\/secure.gravatar.com\/avatar\/cc890e21b652d07da9edf3edeae59188.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F7fa9%2Fimg%2Favatars%2Fava_0008-192.png",
            "image_512": "https:\/\/secure.gravatar.com\/avatar\/cc890e21b652d07da9edf3edeae59188.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F7fa9%2Fimg%2Favatars%2Fava_0008-512.png"
        },

A problem when exporting is done in Slack ? did I miss something to tick ?

@lc3t35
Copy link
Author

lc3t35 commented Oct 12, 2016

Solved by (importing is ok , got all expected users/channels/posts)

if user.profile.email
    userId = Accounts.createUser { email: user.profile.email, password: Date.now() + user.name + user.profile.email.toUpperCase() }
else
    userId = Accounts.createUser { username: user.name, password: Date.now() + user.name }

submitting PR ...

lc3t35 pushed a commit to lc3t35/Rocket.Chat that referenced this issue Oct 12, 2016
…ername: user.name if it does not exist in user record
@acrogenesis
Copy link

I'm getting this error, I'm testing on the develop branch

Exception in defer callback: Error: Match error: Failed Match.OneOf, Match.Maybe or Match.Optional validation     at exports.check (packages/check/match.js:34:1)     at [object Object].Meteor.methods.setAvatarFromService (server/methods/setAvatarFromService.coffee:5:3)     at [object Object].methodsMap.(anonymous function) (packages/rocketchat:lib/server/lib/debug.js:17:26)     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12)     at packages/ddp-server/livedata_server.js:1624:18     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)     at Server.apply (packages/ddp-server/livedata_server.js:1623:45)     at Server.call (packages/ddp-server/livedata_server.js:1566:17)     at [object Object].<anonymous> (packages/rocketchat_importer-slack/server.coffee:135:16)     at packages/dispatch_run-as-user/packages/dispatch_run-as-user.js:186:1     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)     at Object.Meteor.runAsUser (packages/dispatch_run-as-user/packages/dispatch_run-as-user.js:185:1)     at [object Object].<anonymous> (packages/rocketchat_importer-slack/server.coffee:127:15)     at packages/dispatch_run-as-user/packages/dispatch_run-as-user.js:186:1     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)    

@lc3t35
Copy link
Author

lc3t35 commented Oct 14, 2016

@acrogenesis see #4495, it's solved ;)

@engelgabriel engelgabriel modified the milestones: 0.43.0, 0.44.0 Oct 17, 2016
@rodrigok rodrigok modified the milestones: 0.44.0, 0.45.0 Oct 25, 2016
engelgabriel added a commit that referenced this issue Oct 26, 2016
fixes #4614 : provides fallback for empty user.profile.email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants