jolicode / slack-php-api

:hash: PHP Slack Client based on the official OpenAPI specification
https://jolicode.github.io/slack-php-api/
MIT License
224 stars 56 forks source link

long chat message throws an Exception #107

Closed FalkoHilbert closed 3 years ago

FalkoHilbert commented 3 years ago

Hi, we have been using this really super working library for some time. However, today we noticed that for very long messages sent with the chatPostMessage function, an error is thrown with the content isfile(): File name is longer than the maximum allowed path length on this platform (4096):. Do you guys have any idea how I can solve this problem? File: /vendor/jane-php/open-api-runtime/Client/Psr18Client.php Function: executePsr7Endpoint

damienalexandre commented 3 years ago

Hi!

Do you happen to have a longer stacktrace? Because I don't find an isfile method neither in the client nor in JanePHP.

Thanks!

FalkoHilbert commented 3 years ago

Hi,

I didn't have a stacktrace yet, but i think the following line is the reason: https://github.com/janephp/open-api-runtime/blob/1c5248ed5e453b32e8afb325b180d010768a472e/Client/Client.php#L61

Korbeil commented 3 years ago

Hey @FalkoHilbert, thanks for your report, it seems this bug is more related with https://github.com/janephp/janephp, that's why I'm taking back here :) Could you provide us what is your OS, PHP version (php --version), slack-php-api (composer info) version and a code example (with the path your are using) to help us reproduce your issue ?

Thanks !

FalkoHilbert commented 3 years ago

Hi, i'm using php 7.2.34 on debian 9 jolicode/slack-php-api v2.5.0 -> but it looks like it would also be present in higher versions jane-php/open-api-runtime v5.3.3 jane-php/json-schema-runtime v5.3.3

<?php
declare(strict_types=1);

require_once( 'vendor/autoload.php' );

use Faker\Factory;
use JoliCode\Slack\ClientFactory;

$client = ClientFactory::create(SLACK_TOKEN);

$faker = Factory::create();
$veryLongBody = $faker->text(4096);

$client->chatPostMessage(
    [
        'text' => 'Test message',
        'blocks' => json_encode([
            [
                'type' => 'section',
                'text' => [
                    'type' => 'plain_text',
                    'text' => $veryLongBody
                ]
            ]
        ]),
        'channel' => 'YOUR USER ID HERE',
        'as_user' => true
    ]
);

I Hope it will help

damienalexandre commented 3 years ago

We were not able to reproduce the error, but it should be fixed by #108.

Could you please try it? By setting this in your composer.json:

"jolicode/slack-php-api": "dev-upgradeJane"

And then composer update jolicode/slack-php-api.

Thanks a lot!

FalkoHilbert commented 3 years ago

it looks like it is working now

damienalexandre commented 3 years ago

Awesome, just released the patch: https://packagist.org/packages/jolicode/slack-php-api#v4.1.1