Skip to content

Unknown handler id issue #1290

@SarkarSapna

Description

@SarkarSapna

Getting unknow handler id issues when any select event or other event fire. How to resolve the issue

Error
Unknown handler id: C:.Users.labadmin.Desktop.sa...ServiceNow.set_assignment_group.f64511b3a5da324edfc9378e3b469bdc8e5463d909a2bd131a575e2af8d46e75 from event states {
states {
data: "{"show_servicenowdata": false, "filter_incident_data": {}, "assigned_to_list": ["Ab ", "Du", "Vin", "NOT ASSIGNED"], "assignment_group_options": [], "virtual_im_data": [{"id": "68397a6771c983a349d54aa4", "precedence_number": "1", "short_description": "Creating new ticket", "number": "INC0030459", "assigned_to": "NOT ASSIGNED", "reason": "This ticket is required immediate attention due to critical priority and state indicating it's new, with all deadlines being imminent and a very close response time indicating an urgent need for action.", "action": "Immediate attention required. Create a new ticket for further investigation and escalate the issue to the relevant team since the user has initiated this action."}, {"id": "68397a6871c983a349d54aa6", "precedence_number": "2", "short_description": "Password reset VIP user", "number": "INC", "assigned_to": "NOT ASSIGNED", "reason": "This ticket has a critical priority and also requires immediate action due to its status of being new and the urgency surrounding a VIP user's password reset.", "action": "Immediate action needed to reset the password for the VIP user. Assign this ticket to the support team directly for prompt resolution."},{"id": "683", "precedence_number": "2", "short_description": "Password reset", "number": "INC0", "assigned_to": "Du ", "reason": "This ticket comes second as it shows important urgency with a high priority and an imminent SLA, but it lacks the critical designation present in the first ticket.", "action": "Proceed with the password reset as per the user's comment. Confirm successful completion and inform the user. Ensure that documentation is updated reflecting the status of this incident."}], "virtual_im_filter": "", "assigned_group_selected": "", "assigned_to_selected": "", "work_notes_value": "", "additional_comments_value": "", "incident_state_data": "", "assigned_to_options": ""}"
}
}
handler_id: "C:.Users.labadmin.Desktop.sapna...ServiceNow.set_assignment_group.f64511b3a5da324edfc9378e3b469bdc8e5463d909a2bd131a575e2af8d46e75"
key {
}
bytes_value: "\n\nCmp2 group"
viewport_size {
width: 1280
height: 559
}
theme_settings {
prefers_dark_theme: false
theme_mode: THEME_MODE_LIGHT
}
Traceback
C:\Users\labadmin\Desktop\sa.venv\Lib\site-packages\mesop\server\server.py:225 | generate_data
for _ in result:
C:\Users\labadmin\Desktop\sa.venv\Lib\site-packages\mesop\runtime\context.py:374 | run_event_handler
raise MesopException(

My code
def data():

state = me.state(State)
with me.box(
    style=me.Style(
        padding=me.Padding.all(20),
        background=me.theme_var("surface-container-lowest"),
        border=me.Border.all(me.BorderSide(
            width="0.5px", color="#d3d3d3", style="solid")),
       
        box_shadow="0 4px 8px rgba(0, 0, 0, 0.1)"
    )
):
    me.text("Incident Details", type="headline-6")
    

    # Layout for two key-value pairs per row
    data_keys = list(state.filter_incident_data.keys()) // state.filter_incident_data contains object with key pair values
    for key in data_keys: # Iterate through each key individually
        value = state.filter_incident_data[key]
        # Each key-value pair gets its own row (wrapped in a box for consistent styling)
        with me.box(style=me.Style(margin=me.Margin(bottom=15))):
            render_form_field(key, value, state)


    
    me.button("Save", on_click=on_save_incident, style=me.Style(margin=me.Margin(top=20)))

Helper function to render form fields based on key

def render_form_field(key: str, value, state: State):
with me.box(style=me.Style(flex_grow=1)): # Allows fields to take equal space
# Check if the current value is a dictionary (nested object)
if isinstance(value, dict):
# If it's a nested object, display its own key and then iterate through its contents
with me.box(style=me.Style(margin=me.Margin(bottom=10))):
me.text(f"{key.capitalize()} : ", style=me.Style(font_weight="medium",margin=me.Margin(bottom=10)))
with me.box(style=me.Style(margin=me.Margin(left=20))): # Indent nested fields
for sub_key, sub_value in value.items():
# Recursively call render_form_field for nested key-value pairs
# or display them as plain text if no specific component needed
with me.box(style=me.Style(display="flex", flex_direction="row", align_items="baseline", margin=me.Margin(bottom=10))):
me.text(f"{sub_key.capitalize()} : ", style=me.Style(font_weight="medium"))
me.text(str(sub_value))
if key == "assignment_group":
me.text(f"{key.capitalize()} : ", style=me.Style(font_weight="medium", margin=me.Margin(bottom=5)))
me.select(

            options=[me.SelectOption(label=opt, value=opt) for opt in state.assignment_group_options],
            value=state.assigned_group_selected, # Default value
            on_selection_change=set_assignment_group,
            style=me.Style(width="60%") # Ensure it takes full width of its box
        )

Event handlers for updating state

def set_assignment_group(e: me.SelectSelectionChangeEvent):
state = me.state(State)
state.assigned_group_selected = e.value
print(f"Assignment group changed to: {e.value}") # For debugging

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions