Skip to content

ValidationElement.validate() raises KeyError: 'error' after removing error via the public props() API #5977

@manu-ns

Description

@manu-ns

First Check

  • I added a very descriptive title here.
  • This is not a security issue (those should be reported via the security advisory instead).
  • This is not a Q&A. I am sure something is wrong with NiceGUI or its documentation.
  • I used the GitHub search to find a similar issue and came up empty.

Example Code

from nicegui import ui

input_element = ui.input(value="valid", validation=lambda value: None if value else "required")

input_element.props(remove="error error-message")
input_element.validate()

Description

I am using a validated ui.input and clearing Quasar validation props through NiceGUI's public props() API.

I expect either:

  • the public API to reject removal of reserved validation props, or
  • validate() to recover gracefully.

What currently happens is that validate() raises:

KeyError: 'error'

This seems to happen because ValidationElement.error later reads self._props['error'], but that key can still be removed through props(remove="error ...").

NiceGUI Version

3.9.0

Python Version

3.12.3

Browser

Chrome

Operating System

Linux

Additional Context

This looks related to #3809, which also hit a ValidationElement KeyError around the reserved error prop. The trigger here seems different: in this case the key can be removed through the public props(remove="error ...") API and the later validate() call then crashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisStatus: Requires team/community input

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions