Autodialer - expired status is recorded as failed

Hello, everyone.
Since last autumn for some reason a number of expired calls are recorded in the CDR database as failed, although in archived call files they have the EXPIRED status. How can I correct this? I need them to be recorded with the NOANSWER result.

In logs I see: NOTICE[7489]: pbx_spool.c:450 attempt_thread: Call failed to go through, reason (3) Remote end Ringing
NOTICE[7489]: pbx_spool.c:453 attempt_thread: Queued call to … expired without completion after 0 attempts

If I enable pjsip history, I see the following message: SIP/2.0 487 Request Terminated

The call file has failed, and it has failed because the total time to complete it has expired. Each attempt will get a NOANSER, but the call file itself has expired. It would still be expired if each attempt got BUSY.

487 is the response to CANCEL, and Asterisk will always send CANCEL to a SIP call that is considered UNANSWERED.

Is it possible to mark such calls as NO ANSWER in CDR’s?

Looking deeper, it appears that a CDR status of NOANSWER is tied to DIALSTATUS and that is only set for Dial and Queue, not for spooled calls. FAILED is the fallback for cases where there is no dial status, there is no answer time, and the channel doesn’t have a clearing cause set.

I guess, is you used a Local channel, and used the CDR from the DIal, rather than from the call file processing, you could get a NOANSWER status.

Expired is the status of the call file, not, I believe, the individual call attempt.