Skip to content

Expose options from simple alternation match() schemas in UI schema - #7023

Closed
kingpanther13 wants to merge 4 commits into
home-assistant:mainfrom
kingpanther13:ui-schema-match-options
Closed

Expose options from simple alternation match() schemas in UI schema#7023
kingpanther13 wants to merge 4 commits into
home-assistant:mainfrom
kingpanther13:ui-schema-match-options

Conversation

@kingpanther13

@kingpanther13 kingpanther13 commented Jul 9, 2026

Copy link
Copy Markdown

Proposed change

Schema elements of type match() are rendered in the UI as plain string fields
with no suggestions, even when the regex is a simple alternation of literal
values. The Samba add-on's enabled_shares
(match(^(?i:(addons|addon_configs|backup|config|media|share|ssl))$)) is the
visible case: the configuration UI shows a multi-value field with an empty
suggestion list (home-assistant/frontend#51510).

This extracts literal options from match() patterns that are fully anchored
alternations of plain literals and includes them as options on the UI schema
node. Extraction is strictly conservative: the pattern must be anchored with
^...$, and any regex metacharacter, escape, class, quantifier, or nested
group falls back to current behavior. Options are deduplicated preserving
order, and the added tests assert that the emitted options are exactly the
values the pattern accepts (case-insensitively for (?i) patterns), so
suggestions can never produce a value that fails validation.

Validation (AppOptions) is unchanged: fields still validate against the
original regex, so values that only match case-insensitively remain accepted.
Add-on schemas cannot simply switch such fields to list() without breaking
existing configs, since list() validates case-sensitively.

Surveyed all match() patterns across the official add-ons repository and the
largest community repositories (hassio-addons, alexbelgium): 20 of 22 distinct
patterns are unchanged; 2 gain options, both verified to be exactly the
accepted value set.

The frontend counterpart that consumes options on multi-value string nodes:
home-assistant/frontend#53077. Older frontends ignore the additional key.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • 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: Addon config multi-select chip inputs show an empty suggestion list frontend#51510
  • Link to documentation pull request: N/A (the UI schema node format is not
    documented in developers.home-assistant.io; authoring syntax is unchanged)
  • Link to cli pull request: N/A (the CLI does not process the schema field)
  • Link to client library pull request: N/A (aiohasupervisor types schema nodes
    as dict[str, Any]; the additive key needs no model change)

Checklist

  • 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
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@home-assistant home-assistant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @kingpanther13

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

Review findings: unanchored patterns made options non-exhaustive hints
(vol.Match is a prefix match), and an unescaped dot in the literal charset
let wildcard patterns emit misleading options. Options are now exactly the
values the pattern accepts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kingpanther13
kingpanther13 marked this pull request as ready for review July 10, 2026 02:14
@kingpanther13
kingpanther13 marked this pull request as draft July 10, 2026 14:46
@kingpanther13
kingpanther13 marked this pull request as ready for review July 10, 2026 15:40
@agners

agners commented Jul 10, 2026

Copy link
Copy Markdown
Member

2 gain options, both verified to be exactly the
accepted value set.

This seems a rather small group. I think I'd prefer if we release a Samba app which forces the option to be lower case, then do a second release later where we switch from match() to list(). That seems rather straight forward and chances that someone won't update to that intermediate version and uses non-lower case option is rather small. And even if so, the error will make it clear what needs to be changed.

@kingpanther13

Copy link
Copy Markdown
Author

I originally was going to do a PR on Samba, but I went this direction because I was afraid that the change would silently break people's configs. If you feel that this isn't the right way to go I'll happily file a new PR against Samba instead.

@agners

agners commented Jul 11, 2026

Copy link
Copy Markdown
Member

I originally was going to do a PR on Samba, but I went this direction because I was afraid that the change would silently break people's configs. If you feel that this isn't the right way to go I'll happily file a new PR against Samba instead.

Yes, let's change the Samba config. The first step won't be a breaking change. The second step we can bundle with other changes like the new Netbios config default, and mark it clearly as a breaking change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

new-feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants