[Home]

Summary:ASTERISK-28219: res_ari: Channel create and dial may cause "BUG! Must supply a channel name.." error
Reporter:Anil Gupta (anilg8888)Labels:
Date Opened:2018-12-21 06:36:01.000-0600Date Closed:2022-02-14 13:43:15.000-0600
Priority:MinorRegression?
Status:Closed/CompleteComponents:Resources/res_ari_channels
Versions:16.1.0 Frequency of
Occurrence
Frequent
Related
Issues:
is related toASTERISK-27797 channel.c: BUG! Must supply a channel name or partial name to match!
Environment:Attachments:( 0) create-bug.js
Description:Hello!

If /ari/channels/create is called without the optional parameter `originator` it results in the following error:
[Dec 21 12:03:50] ERROR[10769]: channel.c:1311 ast_channel_by_name_cb: BUG! Must supply a channel name or partial name to match!

I am not sure if this happens after a certain threshold of hits or randomly. However, it is easy to reproduce by repeatedly hitting the API. I'll attach a nodejs script in a short while to help reproduce this.
Looking at the code in res/ari/resource_channels.c:ast_ari_channels_create() it seems the originator is queried with ast_channel_get_by_name(originator) and cleaned up by ast_channel_cleanup(originator) without checking if the parameter was provided or not. Wrapping these two lines in
if (!ast_strlen_zero(args->originator)) {
//
}
resolves the issue.
ASTERISK-27797 might be the result of this as the ARI trace attached there indicates that /ari/channels/create is called without the `originator` parameter.

Furthermore, /ari/channels/$channelId/dial behaves the same if the optional parameter `caller` is not provided.

Comments:By: Asterisk Team (asteriskteam) 2018-12-21 06:36:03.194-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Anil Gupta (anilg8888) 2018-12-21 06:46:26.636-0600

script to reproduce the error

By: Sean Bright (seanbright) 2021-11-30 19:10:57.941-0600

I know it's been almost 3 years, but do you happen to remember what compiler and target machine you were using?

By: Sean Bright (seanbright) 2021-12-03 11:11:11.319-0600

The reason that it is sporadic is that the error message is only emitted if at least 1 other channel exists. This is side-effect of the way the code is written. Once the linked review is merged it will no longer emit the message.

By: Friendly Automation (friendly-automation) 2021-12-06 10:14:36.123-0600

Change 17590 merged by Kevin Harwell:
channel: Short-circuit ast_channel_get_by_name() on empty arg.

[https://gerrit.asterisk.org/c/asterisk/+/17590|https://gerrit.asterisk.org/c/asterisk/+/17590]

By: Friendly Automation (friendly-automation) 2021-12-06 10:19:40.082-0600

Change 17616 merged by Friendly Automation:
channel: Short-circuit ast_channel_get_by_name() on empty arg.

[https://gerrit.asterisk.org/c/asterisk/+/17616|https://gerrit.asterisk.org/c/asterisk/+/17616]

By: Friendly Automation (friendly-automation) 2021-12-06 10:19:45.073-0600

Change 17617 merged by Friendly Automation:
channel: Short-circuit ast_channel_get_by_name() on empty arg.

[https://gerrit.asterisk.org/c/asterisk/+/17617|https://gerrit.asterisk.org/c/asterisk/+/17617]

By: Friendly Automation (friendly-automation) 2021-12-06 10:24:29.680-0600

Change 17618 merged by Kevin Harwell:
channel: Short-circuit ast_channel_get_by_name() on empty arg.

[https://gerrit.asterisk.org/c/asterisk/+/17618|https://gerrit.asterisk.org/c/asterisk/+/17618]