Skip to content

Conversation

@abmantis
Copy link
Member

@abmantis abmantis commented Nov 8, 2025

Proposed change

Update the mfa setup schema so that voluptuous_serialize can serialize it. Previously, it was failing and making it impossible to set up MFA notify:

  File "/usr/src/homeassistant/homeassistant/components/auth/mfa_setup_flow.py", line 117, in async_setup_flow
    websocket_api.result_message(msg["id"], _prepare_result_json(result))
                                            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/auth/mfa_setup_flow.py", line 163, in _prepare_result_json
    data["data_schema"] = voluptuous_serialize.convert(schema)
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/voluptuous_serialize/__init__.py", line 59, in convert
    pval = convert(value, custom_serializer=custom_serializer)
  File "/usr/local/lib/python3.13/site-packages/voluptuous_serialize/__init__.py", line 164, in convert
    raise ValueError(f"Unable to convert schema: {schema}")
ValueError: Unable to convert schema: <class 'str'>

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@abmantis abmantis requested a review from a team as a code owner November 8, 2025 21:49
Copilot AI review requested due to automatic review settings November 8, 2025 21:49
@abmantis abmantis added this to the 2025.11.2 milestone Nov 8, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the schema construction in the notification MFA module to use a more concise and modern approach. The changes remove the dependency on OrderedDict and simplify schema creation by using direct dictionary literals within vol.Schema().

Key changes:

  • Removes unused OrderedDict import from the notify MFA module
  • Refactors schema construction from a multi-step OrderedDict approach to an inline dictionary literal
  • Adds test coverage to verify the schema can be serialized correctly with voluptuous_serialize

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
homeassistant/auth/mfa_modules/notify.py Removes OrderedDict import and simplifies schema construction by using inline dict with vol.Required/vol.Optional markers directly in vol.Schema()
tests/auth/mfa_modules/test_notify.py Adds voluptuous_serialize import and test assertion to verify schema serialization produces the expected structure with proper field ordering

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @abmantis 👍

../Frenkc

@frenck frenck merged commit 88b6754 into dev Nov 9, 2025
71 of 72 checks passed
@frenck frenck deleted the mfa_notify_schema_fix branch November 9, 2025 08:13
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants