WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API
https://baileys.whiskeysockets.io/
MIT License
3.95k stars 1.34k forks source link

[BUG] bad-request in sock.profilePictureUrl #1024

Open adithyan-hermit opened 2 months ago

adithyan-hermit commented 2 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Created a new connection
  2. Closed & used saved credentials to log back in
  3. Etc.

Expected behavior A clear and concise description of what you expected to happen.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

Error: bad-request at assertNodeErrorFree (/root/hermit-bot/node_modules/@WhiskeySockets/baileys/lib/WABinary/generic-utils.js:56:15) at query (/root/hermit-bot/node_modules/@WhiskeySockets/baileys/lib/Socket/socket.js:145:48) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.profilePictureUrl (/root/hermit-bot/node_modules/@WhiskeySockets/baileys/lib/Socket/chats.js:442:24) { data: 400, isBoom: true, isServer: true, output: { statusCode: 500, payload: { statusCode: 500, error: 'Internal Server Error', message: 'An internal server error occurred' }, headers: {} } }

codexJoin commented 2 months ago

This error occurs when the account does not have a profile picture. In this case, I recommend catching the error and either returning false or generating a thumbnail for the user.

See example what i use:


async get_avatar(){
        const ppUrl = await this.WASocket.profilePictureUrl(this.WASocket.user?.id ?? '').then((ppUrl) => ppUrl)
            .catch((ex) => {
                return random_avatar_byname(this.WASocket.user?.name);
            });
        return ppUrl;
    }
adithyan-hermit commented 2 months ago

This error occurs when the account does not have a profile picture. In this case, I recommend catching the error and either returning false or generating a thumbnail for the user.

See example what i use:

async get_avatar(){
        const ppUrl = await this.WASocket.profilePictureUrl(this.WASocket.user?.id ?? '').then((ppUrl) => ppUrl)
            .catch((ex) => {
                return random_avatar_byname(this.WASocket.user?.name);
            });
        return ppUrl;
    }

Ya but it's only working when get my own jid profile not working of others jid. (Who has profile)

Rippanteq7 commented 2 months ago

Use latest version of baileys, it should have been fixed in #901

adithyan-hermit commented 2 months ago

Use latest version of baileys, it should have been fixed in #901

Already using baileys 6.7.7

benaysuman commented 2 months ago

I have the same issue, not with all profile pictures but alot give back an error. The error is different from the error that it gives when there is no profile picture.