question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

invalid_array_arg when trying to change the user status

See original GitHub issue
  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Description

I’m trying to update the status of my bot using the web client, but it fails with an error: invalid_array_arg

Steps to reproduce:

import * as SlackClient from '@slack/client';

const slackWebClient = new SlackClient.WebClient(botToken);
slackWebClient.users.profile.set({ 
  profile: {
     status_text: 'riding a train',
     status_emoji: ':mountain_railway:'
  }
});

Expected result:

Status of my bot is changed

Actual result:

It fails with an error invalid_array_arg

Attachments:

error: Response not OK:  invalid_array_arg
Unhandled rejection Error: invalid_array_arg
    at handleHttpResponse (C:\Projects\slack-app\node_modules\@slack\client\lib\clients\transports\call-transport.js:103:17)
    at handleTransportResponse (C:\Projects\slack-app\node_modules\@slack\client\lib\clients\transports\call-transport.js:153:19)
    at apply (C:\Projects\slack-app\node_modules\lodash\lodash.js:499:17)
    at wrapper (C:\Projects\slack-app\node_modules\lodash\lodash.js:5356:16)
    at Request.handleRequestTranportRes (C:\Projects\slack-app\node_modules\@slack\client\lib\clients\transports\request.js:20:5)
    at apply (C:\Projects\slack-app\node_modules\lodash\lodash.js:499:17)
    at Request.wrapper [as _callback] (C:\Projects\slack-app\node_modules\lodash\lodash.js:5356:16)
    at Request.self.callback (C:\Projects\slack-app\node_modules\request\request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (C:\Projects\slack-app\node_modules\request\request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (C:\Projects\slack-app\node_modules\request\request.js:1091:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
aoberoicommented, Jun 19, 2017

thanks for the bug report, i was able to reproduce, so i’m labeling it accordingly.

here is a debug dump i captured while reproducing:

REQUEST { url: 'https://slack.com/api/users.profile.set',
  headers: { 'User-Agent': '@slack:client/3.10.0 darwin/16.6.0 node/4.7.0' },
  form: 
   { profile: 
      { status_text: 'riding a train',
        status_emoji: ':mountain_railway:' },
     token: 'xoxb-REDACTED' },
  callback: [Function: wrapper],
  method: 'POST' }
REQUEST make request https://slack.com/api/users.profile.set
REQUEST onRequestResponse https://slack.com/api/users.profile.set 200 { 'content-type': 'application/json; charset=utf-8',
  'content-length': '40',
  connection: 'close',
  'access-control-allow-origin': '*',
  date: 'Mon, 19 Jun 2017 17:54:16 GMT',
  'referrer-policy': 'no-referrer',
  server: 'Apache',
  'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-slack-backend': 'h',
  'x-slack-req-id': '783239fc-d103-4511-8616-4afaeb69d4fc',
  'x-xss-protection': '0',
  'x-cache': 'Miss from cloudfront',
  via: '1.1 d5da2738774b6f83465e13845679d084.cloudfront.net (CloudFront)',
  'x-amz-cf-id': 'bsZ50ZBkUjW9AYnqQpvqhtu6N2jqLr4W7kRRPLBXom4f4iQBPr7Fbw==' }
REQUEST reading response's body
REQUEST finish init function https://slack.com/api/users.profile.set
REQUEST response end https://slack.com/api/users.profile.set 200 { 'content-type': 'application/json; charset=utf-8',
  'content-length': '40',
  connection: 'close',
  'access-control-allow-origin': '*',
  date: 'Mon, 19 Jun 2017 17:54:16 GMT',
  'referrer-policy': 'no-referrer',
  server: 'Apache',
  'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-slack-backend': 'h',
  'x-slack-req-id': '783239fc-d103-4511-8616-4afaeb69d4fc',
  'x-xss-protection': '0',
  'x-cache': 'Miss from cloudfront',
  via: '1.1 d5da2738774b6f83465e13845679d084.cloudfront.net (CloudFront)',
  'x-amz-cf-id': 'bsZ50ZBkUjW9AYnqQpvqhtu6N2jqLr4W7kRRPLBXom4f4iQBPr7Fbw==' }
REQUEST end event https://slack.com/api/users.profile.set
REQUEST has body https://slack.com/api/users.profile.set 40
REQUEST emitting complete https://slack.com/api/users.profile.set
error: Response not OK:  invalid_array_arg
[Error: invalid_array_arg]

it looks like the value for profile is getting serialized as profile[status_text]=...&profile[status_message]=... rather than profile={"status_text":"...","status_message":"..."}. This serialization is done for similar greater-than-one level JSON arguments in the assignApiArgs() function. My suggested fix is to add an additional condition in there for when key === 'profile'. I can probably get around to this in the next week or so, but PRs welcome too!

0reactions
mhdatiecommented, Aug 29, 2017

I’m experiencing the same issue when updating the status

Read more comments on GitHub >

github_iconTop Results From Across the Web

chat unfurl invalid array argument · Issue #1522 · howdyai/botkit
I have issue using bot.api.chat.unfurl, according the unfurl API everything should be correct. Error debug: Got response null {"ok":false ...
Read more >
How to use try catch to replace invalid data of user input array ...
I want it to kick out the invalid input, and prompt the user to re-enter a valid input, and keep building it. import...
Read more >
RangeError: invalid array length - JavaScript - MDN Web Docs
The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds ...
Read more >
Error handling - Apollo GraphQL Docs
The GraphQL operation is not valid against the server's schema. BAD_USER_INPUT. The GraphQL operation includes an invalid value for a field argument.
Read more >
JavaScript RangeErrors and How to Prevent Them
A RangeError is used to convey to a user that a value was passed into a ... an uncaught RangeError with the message...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found