universal_notifier icon indicating copy to clipboard operation
universal_notifier copied to clipboard

Attachment data keys (url, file_path, etc.) leak into tts.speak payload, breaking voice channel dispatch

Open jokerigno opened this issue 5 months ago • 2 comments

Bug

In __init__.py, Sezione I ("Merge Dati Accessori"), extra data passed to universal_notifier.send (e.g. url, file_path for photo/document attachments) is merged into service_payload for any non-notify domain, including tts:

# __init__.py, ~line 477-482
if all_additional_data:
    if srv_domain == "notify":
        if "data" not in service_payload: service_payload["data"] = {}
        service_payload["data"].update(all_additional_data)
    else:
        service_payload.update(all_additional_data)

Only volume, type and parse_mode are stripped beforehand. When a call targets a voice channel (service: tts.speak) and also carries attachment-style keys (typical for a multi-target call that fans out to both a text/photo channel and a voice channel, e.g. data: {type: photo, url: ...} with targets: ["SomeoneText", "SomeoneVoice"]), those keys end up in the tts.speak payload, which rejects them:

UniNotifier: Errore nel worker vocale: extra keys not allowed @ data['file_path']
UniNotifier: Errore nel worker vocale: extra keys not allowed @ data['url']

This silently breaks the voice notification for that target (caught generically in voice_queue_worker's except Exception), even though the voice channel itself never asked for an attachment.

Fix

Exclude the tts domain from the generic merge, since tts.speak has its own fixed schema and never accepts attachment-style keys:

if all_additional_data:
    if srv_domain == "notify":
        if "data" not in service_payload: service_payload["data"] = {}
        service_payload["data"].update(all_additional_data)
    elif srv_domain != "tts":
        service_payload.update(all_additional_data)
    # tts.speak doesn't accept extra keys like url/file_path/caption

We've applied this locally and confirmed it resolves the worker error (tested on dev_improvment).

Context

Found while investigating recurring Errore nel worker vocale: extra keys not allowed @ data[...] log entries triggered by automations that send the same notification to both a Telegram/photo channel and a voice channel in one universal_notifier.send call.

Tested against dev_improvment branch (v0.8.0).

jokerigno avatar Jun 16 '26 14:06 jokerigno

Still not fixed in v0.8.1 (released 2026-06-14).

In v0.8.1 __init__.py, Sezione I still reads:

if all_additional_data:
    if srv_domain == "notify":
        if "data" not in service_payload: service_payload["data"] = {}
        service_payload["data"].update(all_additional_data)
    else:
        service_payload.update(all_additional_data)  # ← tts still included

The else branch still covers tts (and any other non-notify domain), injecting url, file_path, caption etc. directly into the tts.speak payload and causing schema validation errors on multi-target calls.

I am running a local patch that changes else: to elif srv_domain != "tts": to exclude the TTS domain from the merge.

jokerigno avatar Jun 16 '26 21:06 jokerigno

Please follow the issue template to help me understand your issue better.
Add action performed and configuration of Universal Notifier

jumping2000 avatar Jun 16 '26 23:06 jumping2000