mrkaye97 / slackr

An R package for sending messages from R to Slack
https://matthewrkaye.com/slackr/
Other
307 stars 85 forks source link

'id' column not found in lhs #52

Closed isomorphisms closed 3 years ago

isomorphisms commented 7 years ago
> dev.slackr('#microcuke')
Error: 'id' column not found in lhs, cannot join
isomorphisms commented 7 years ago
> slackr(str(tail(RHT)))
Error: 'id' column not found in lhs, cannot join
stanasa commented 7 years ago

I had the same problem until I created a ~/.slackr file with the following structure: api_token: YOUR_TOKEN_HERE channel: #myslackchannel username: myslackname incoming_webhook_url: https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZ the token came from here: https://api.slack.com/docs/oauth-test-tokens. A bit confusing, since the setup instructions say the api token is deprecated. make sure the username is your actual slack user.

yangla030812 commented 7 years ago

Hi Stanasa, I got the same error. But how did you create a ~/.slackr file? Where should it be put? Thanks.

hrbrmstr commented 7 years ago

I'll try to carve out some time for this but I'm also not sure what Slack did API-change-wise (my workplace has not authorized slackr so it's hard to get cycle-time for enhancements.

hrbrmstr commented 7 years ago

i've not run into issues with the legacy API tokens https://api.slack.com/custom-integrations/legacy-tokens (OAuth 2.0 support is not avail yet)

yonicd commented 7 years ago

same issue. i created the ~/.slackr file and still get same error

yonicd commented 7 years ago

nm. i was looking at the documentation in an old post (it has the field token instead of api_token).

everything works fine. i would make the error returned when a channel or id is not found in Slack to be more informative.

Error in charToRaw(enc2utf8(val)) : 
  argument must be a character vector of length 1
smach commented 7 years ago

I used the old version of slackr without problem, now I'm trying to use the new one and I'm getting Error: 'id' column not found in lhs, cannot join as well.

I've got a .slackr file in my home directory with format

api_token: MY TOKEN FROM LEGACY API TOKEN PAGE channel: #mychannel username: my.name incoming_webhook_url: https://hooks.slack.com/services/XXXX/xxxxxxx

Any other idea what I might be doing wrong? Are there special settings for the incoming webhook?

Thanks

yonicd commented 7 years ago

you should get a more informative output if you run slackr::slackrSetup(echo=TRUE) from the console. if there are fields missing it will be more obvious there.

smach commented 7 years ago

@yonicd Thanks. Everything seems to be there except that SLACK_ICON_EMOJI is "NA". Now I'm back to getting the original Error in charToRaw(enc2utf8(val)) : argument must be a character vector of length 1 error. I suspect I may have done something wrong setting up either the webhook or the API token, although the API token seems pretty straightforward given the link above. is there something I need to do to make sure the webhook can use that particular token?

yonicd commented 7 years ago

lets dig a bit deeper and see what the api is returning. the api should return an informative error.

try running:

slackr::slackrSetup()
tmp <- httr::POST("https://slack.com/api/users.list", body=list(token=Sys.getenv("SLACK_API_TOKEN")))
jsonlite::fromJSON(httr::content(tmp, as="text"))
smach commented 7 years ago

@yonicd Thank you very much for trying to help. Oddly, I don't see anything in the tmp list contents that looks like an error. Status code 200, no obvious errors.

yonicd commented 7 years ago

200 is an odd response, if everything was ok you should of gotten a named list with the objects c('ok','members','cache_ts').

anyhow if you built a slack app for the webhook you should be able to navigate to your app https://api.slack.com/apps. and then under features go to the incoming webhooks to check what channel the webhook is connected to.

smach commented 7 years ago

tmp[[2]] showed name of status_code and value of 200. I got a list of 10. Either my web hook is wrong or my api token is wrong, I think.

yonicd commented 7 years ago

the api scheme has changed in the last year so you may need to reset it.

smach commented 7 years ago

@yonicd That must be it! I'm afraid to re-issue the API token in my work Slack until I inventory any apps that might be affected, but I just tried it on another Slack workspace with a new API token and it works fine. Now I know to reissue the API token at work once I can. Thanks!

yonicd commented 7 years ago

great to hear! lots of new toys to play with in slackr, enjoy

DaniMori commented 6 years ago

Got the same error when using function "slackr", not with "slackr_bot"

mzaret2000 commented 6 years ago

This happened to me. Here's how I fixed it.

This error problem popped up for me with ggslackr for a script that I had written over two years ago. I tried re-issuing the legacy api token but it would not cooperate.

I was able to get it working again after creating a new bot and then granting the set of permissions ("Scopes") needed to access all the api methods called in the ggslackr function. ggslackr calls /api/files.upload and also via slackr_chtrans it calls /api/group.list, /api/im.list and /api/users.list. Each of these methods requires some permissions that you can add in the OAuth & Permissions section of your slack bot.

screen shot 2018-07-27 at 2 53 28 pm

nknauer commented 4 years ago

Do I need all of these? I am not a slack admin so wondering what are the scopes necessary

briholt100 commented 3 years ago

I am also having this issue of Error: Join columns must be present in data. x Problem withid``

The curl test case offered up by Slack after setting webhooks and tokens works. I can post using that method.

But from within slackr, I get the Problem with ID.

If I run from slackr::slackrSetup(echo=TRUE) I get the following:

{
  "SLACK_CHANNEL": ["#general"],
  "SLACK_USERNAME": ["slackr_brian"],
  "SLACK_ICON_EMOJI": ["NA"],
  "SLACK_INCOMING_URL_PREFIX": ["https://hooks.xxxxxxx"],
  "SLACK_API_TOKEN": ["token secret"]
}

Not sure where to go from here. Cheers all.

This user over on stackoverflow suggested changing the function code (!) slackr_ims():

dplyr::left_join( %some stuff% )
suppressWarnings( merge(users, ims, by.x="id", by.y='user') )

But that seems extreme.

kburnham-zen commented 3 years ago

This error appears to come from the function slackr_ims, specifically the line ims <- jsonlite::fromJSON(httr::content(tmp, as = "text"))$ims. The API responds to this request with an error and the message "[ERROR] This method is retired and can no longer be used. Please use conversations.list or users.conversations instead. Learn more: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api.".

That url indicates that several APIs, including im will be deprecated for new apps as of November 25th 2020 and for all apps on Feb 24th 2021.

The reason that the error is not very informative is because the code does not check to make sure that a meaningful reply was received but instead attempts to join it to the users table on the "id" column which of course does not exist, hence the "id column not found" error.

It appears to be the case that if this issue is not fixed slackr will stop working for all users on 2/24/2021.

mrkaye97 commented 3 years ago

@kburnham-zen Nice catch! I'll put in a fix for this when I get a minute and PR it. I asked @hrbrmstr for write access to the repo, so I'll be able to fix this on the fly if that happens.

orenscarmeli commented 3 years ago

My team has been getting the following issue since 2/24/2021

Error: Join columns must be present in data.
x Problem with `id`.

Happens when we use. Message is a csv in this case. slackr_upload(message, channels = channel, ...)

However, we are able to send a text message to slack, just not a csv / xlsx file. The below works text_slackr(text = message, channel = channel, as_user = "ds-slackr")

Is there a workaround?

mrkaye97 commented 3 years ago

@orenscarmeli What version are you on, and what scopes do you have enabled? Nothing has changed in the past few weeks, so I'm not sure why you'd only have been getting this error since yesterday.

Also FWIW, text_slackr is deprecated in favor of slackr_msg in 2.1.0+

kburnham-zen commented 3 years ago

Probably has to do with the deprecation of certain APIs for all slack users noted above^

mrkaye97 commented 3 years ago

@kburnham-zen I can't reproduce this error locally and slackr_upload works fine for me, so I assume that this is just an old slackr version issue

orenscarmeli commented 3 years ago

@mrkaye97 currently using rstudio 4.0.3. Our team fixed by forking the repo to a commit where the slackr_upload works. Also changed text_slackr to slackr_msg

  `# older versions fail with this issue: https://github.com/mrkaye97/slackr/pull/102` \
  `# newer versions fail with this issue: https://github.com/mrkaye97/slackr/issues/140` \
  katrinabrock/slackr@9a68e3acd8812c38a82adb178bcdbbbe4678f7a1 <- what we forked
mrkaye97 commented 3 years ago

@orenscarmeli A couple clarifying things:

  1. I meant which slackr version you're on (not which R version). I'm assuming you're on an old version, and I think that running devtools::install_github('mrkaye97/slackr') to upgrade to the most recent version will fix this issue.
  2. The fork that you forked is (I think) on a more recent version than you're on, where this issue is fixed. That's why I think that updating will fix your issue.

Give installing the dev version from Github a shot and see if that fixes the issue. It'll be a more stable fix than having a separate fork.

stale[bot] commented 3 years ago

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.