Skip to content

config: invalid 're:' match pattern crashes startup and GET /api/config instead of failing validation #118

Closed

Description

@falbany

Problem

A re:-prefixed match pattern is validated nowhere and compiled nowhere until match time — where re.search raises, taking down app startup and every config endpoint.

# src/profiles/core/config/matcher.py:31-34
if pattern.startswith("re:"):
    regex = pattern[3:]
    target = _normalize_path(value) if is_path else value
    return bool(re.search(regex, target, re.IGNORECASE))  # raises on invalid regex

MatchCriteriaSchema (src/profiles/core/config/schema.py:161-175) accepts any string and collect_issues (validator.py) never checks patterns.

Verified crash paths

  • hostname: ["re:([unclosed"] loads cleanly, then matches_machine_config raises re.error: unterminated character set.
  • Startup: BackgroundServer.__init__ → choose_active_directory (src/profiles/desktop/lifecycle.py:79, unguarded) → select_active_configuration → matches_machine_config — the app fails to start.
  • Server: GET /api/config → _config_response → find_active_config (src/profiles/server/routes/config.py:116) → 500 for every request.

Suggested fix

  1. Validate at load: a field validator on MatchCriteriaSchema that compiles every re:-prefixed entry and raises ValueError with the offending pattern.
  2. Emit the precise path (configs.<name>.match.hostname[i]) from collect_issues so the editor Problems panel shows it instead of a runtime crash.

Related: #29 (hardening backlog), #44 (validation gaps).

Activity

  1. added
    bug
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions