Skip to content

[symfony/slack-notifier] SLACK_DSN format from documentation produces an error #39915

@yesnik

Description

@yesnik

Symfony version(s) affected: 5.2.1

Description

slack-notifier documentation tells that SLACK_DSN must look like this:

SLACK_DSN=slack://xoxb-......@default?channel=my-channel-name

But this format generates this exception when we try to send notification:

Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven't updated the DSN when upgrading from 5.1). 

How to reproduce

  1. Create new symfony app: symfony new slack-notifier-test
  2. Require slack-notifier: composer req slack-notifier
  3. Edit file config/packages/notifier.yaml to enable chatter transport:
framework:
    notifier:
        chatter_transports:
            slack: '%env(SLACK_DSN)%'
  1. Add your own SLACK_DSN to .env file:
SLACK_DSN=slack://xoxb-449280182032-1632617752622-xYSN4i3olopYlAijAW6PcMO8@default?channel=general
  1. Create file src/Command/NotifyCommand.php:
<?php
namespace App\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Message\ChatMessage;

class NotifyCommand extends Command
{
    protected static $defaultName = 'notify';
    protected $chatter;

    public function __construct(ChatterInterface $chatter)
    {
        $this->chatter = $chatter;
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $message = (new ChatMessage('Hello'))
            ->transport('slack');

        $this->chatter->send($message);

        return Command::SUCCESS;
    }
}
  1. Run console command: symfony console notify. We'll get an error:
[error] Error thrown while running command "notify". Message: "Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven't updated the DSN when upgrading from 5.1)."

Possible Solution

It seems to me that this bug was fixed in this commit: symfony/slack-notifier@da1642c

But why we don't see these changes in the current version of slack-notifier, v.5.2.1?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions