groupme-js / node-groupme

The only GroupMe API library for NodeJS that isn't a million years old.
https://groupme.js.org
MIT License
27 stars 11 forks source link

```Error: Invalid value for key "share_url". Expected type "" but got null``` #65

Closed jeebeeng closed 3 years ago

jeebeeng commented 3 years ago

When attempting to login while I am part of a group where sharing is disabled, the following error is thrown: Error: Invalid value for key "share_url". Expected type "" but got null

not-so-smart commented 3 years ago

Judging by the logs, it looks like this is actually an issue with the Me type.

https://github.com/groupme-js/node-groupme/blob/a20767f8295eade8b082bf3397a174c7504d492c/src/interfaces/Me.ts#L24

I wasn't aware that this field could be null -- would you mind posting the rest of your /users/me payload here?

GET /v3/users/me HTTP/1.1
Host: api.groupme.com
X-Access-Token: {{TOKEN}}

note that this payload contains sensitive information, so be sure to censor the name, email, id, user_id, and phone_number fields however you see fit. Please leave the rest of the payload untouched, so we can make the types as accurate as possible.

logs from discord:

Error: Invalid value for key "share_url". Expected type "" but got null
    at invalidValue         (node-groupme/src/interfaces/Me.ts:57:15)
    at transformPrimitive   (node-groupme/src/interfaces/Me.ts:83:16)
    at transform            (node-groupme/src/interfaces/Me.ts:156:12)
    at node-groupme/src/interfaces/Me.ts:128:32
    at Array.forEach (<anonymous>)
    at transformObject      (node-groupme/src/interfaces/Me.ts:125:43)
    at transform            (node-groupme/src/interfaces/Me.ts:151:53)
    at cast                 (node-groupme/src/interfaces/Me.ts:160:12)
    at toMe                 (node-groupme/src/interfaces/Me.ts:47:16)
    at RESTManager.api      (node-groupme/src/rest/rest.ts:45:27)
jeebeeng commented 3 years ago

Here is the rest of my /users/me payload:

{
    "created_at": 1484000453,
    "email": "myemail@gmail.com",
    "facebook_connected": false,
    "id": "45144360",
    "image_url": "https://i.groupme.com/1024x640.jpeg.08b39cfc3ae24c09b70258575ecd9b63",
    "locale": "en",
    "name": "John Bang",
    "phone_number": "+1 1234567890",
    "sms": false,
    "twitter_connected": false,
    "updated_at": 1635290919,
    "user_id": "45144360",
    "zip_code": null,
    "share_url": null,
    "share_qr_code_url": null,
    "mfa": {
        "enabled": false,
        "channels": [
            {
                "type": "phone_number",
                "created_at": 1598889179
            }
        ]
    },
    "tags": [
        "phone-us"
    ],
    "prompt_for_survey": false,
    "show_age_gate": false,
    "birth_date_set": true
}
not-so-smart commented 3 years ago

it looks like the only properties that contradict the types here are share_url and share_qr_code_url. do you know why these would be null? did you change some setting that disables profile sharing?

jeebeeng commented 3 years ago

I haven't touched any settings related to profile sharing for my groupme account. Not sure if this would be helpful, but my account was created around 2016/2017.

jeebeeng commented 3 years ago

It seems that this feature was added around 2020. Perhaps having an account created before then caused the fields to be null?

not-so-smart commented 3 years ago

I found the culprit -- there's a setting that allows you to turn profile sharing on/off. I'll add this to the todo list for the API docs repo.

Unfortunately the types used in the type checker won't be fixed because we're about to move to groupme-api-types which doesn't have type checkers (yet).

However, feel free to open an issue on groupme-api-types explaining this discrepancy, so that it can be fixed in the next release.

Be sure to include this link in your issue: https://github.com/groupme-js/groupme-api-types/blob/f5115ccec75343b305dd98ec1371fb093dc38360/types/APIClientUser.ts#L15