Skip to content

[Bug]: Incorrect Error Message for Custom Normalizer Registration #1935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JamesHWade opened this issue Mar 20, 2025 · 0 comments · Fixed by #1936
Closed

[Bug]: Incorrect Error Message for Custom Normalizer Registration #1935

JamesHWade opened this issue Mar 20, 2025 · 0 comments · Fixed by #1936
Labels
bug Something isn't working needs-triage

Comments

@JamesHWade
Copy link
Contributor

Component

UI (ui.*)

Severity

P2 - Medium (workaround exists)

Shiny Version

1.3.1

Python Version

3.11

Minimal Reproducible Example

from shiny import App, ui
from typing import Any

# Create a custom message type that won't be recognized by any normalizer
class CustomMessage:
    def __init__(self, content):
        self.content = content

app_ui = ui.page_fillable(
    ui.panel_title("Custom Normalizer Example"),
    ui.chat_ui("chat"),
    fillable_mobile=True,
)

def server(input, output, session):
    chat = ui.Chat(id="chat")

    @chat.on_user_submit
    async def _():
        # This will trigger the error with incorrect guidance
        custom_msg = CustomMessage("Hello")
        await chat.append_message(custom_msg)  # Will raise error with incorrect guidance

app = App(app_ui, server)

Behavior

Current: When a user tries to use a message type that doesn't have a registered normalizer, the error message suggests registering a custom normalizer via shiny.ui._chat_types.registry.register(), which doesn't exist.

Expected: The error message should direct users to the correct path: shiny.ui._chat_normalize.message_normalizer_registry.register().

Error Messages (if any)

ValueError: Could not find a normalizer for message of type <class '__main__.CustomMessage'>: <__main__.CustomMessage object at 0x7f8c1d3e5f90>. 
Consider registering a custom normalizer via shiny.ui._chat_types.registry.register()

Environment

MacOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant