After digging through old mailing posts I've been able to resolve this by applying the changes in the BRANCH route. This fixes the corruption, although the logs still show a warning for applying it twice.

Cheers

On Thu, 7 Mar 2024 at 09:23, Benoit Panizzon <benoit.panizzon@imp.ch> wrote:
Hi Matthew

> However in my scenario I wish to first try one endpoint and then if it gets
> a 4XX response forward it to another UAC, and update the TO accordingly.
>
> Currently trying to call  uac_replace_to twice shows an error and corrupts
> the TO header. Is there a work around for this?

I have no solution, but the same issue. (at the moment more or less
solved by heavily using dialog variables).

Example scenario showing the issue: Numbers are in e164 format, but
towards the customer, shall be translated in localized format and
privacy observed. Assume customer has Call forward on busy active.

So the steps towards the issue are:

* Translate numbers from e164 to local
* If privacy: id replace numbers and display name with 'anonymous'
* branch to customer
* uac_replace
* Manage reply: 486 busy
** Add diversion header ;reason=busy
** Add CFW destination RURI
** dispatch back to routing core.

Towards core, I would need to revert uac_replace and use the original
headers again.

Mit freundlichen Grüssen

-Benoît Panizzon-
--
I m p r o W a r e   A G    -    Leiter Commerce Kunden
______________________________________________________

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch
______________________________________________________