Skip to content

fix: handle list-type host in settings and fix [object Object] error display#908

Open
fqx wants to merge 2 commits intojundot:mainfrom
fqx:fix/settings-host-list-type-coercion
Open

fix: handle list-type host in settings and fix [object Object] error display#908
fqx wants to merge 2 commits intojundot:mainfrom
fqx:fix/settings-host-list-type-coercion

Conversation

@fqx
Copy link
Copy Markdown
Contributor

@fqx fqx commented Apr 23, 2026

Problem

Two related issues with the host setting:

  1. [object Object] when editing settings after manually setting host to a YAML list.
    ServerSettings.from_dict() assigned the list directly to host: str without type checking.
    The web UI received a non-string value, Alpine.js x-model displayed [object Object],
    and saving triggered a Pydantic 422 whose error-object array was joined to [object Object].

  2. No way to bind to multiple addresses from the web UI.
    The host field only accepted a single address. Users had to manually edit settings.yaml
    to use a list, which then broke the web UI (issue 1 above).

Fix

omlx/settings.py — normalize host to a string in from_dict(). YAML list values
are joined with ", " so the web UI can display and edit them as a plain string.
Backward-compatible: existing single-string configs are unchanged.

omlx/admin/static/js/dashboard.js — extract .msg from Pydantic error detail objects
instead of joining the raw objects. Fixes two call sites so errors show readable text
instead of [object Object].

omlx/cli.py — split the host string by comma before calling uvicorn.run().
asyncio.create_server() (used internally by uvicorn) natively accepts a sequence of
hosts and binds a socket for each. The startup message prints one URL per address.

omlx/utils/network.py — add is_valid_bind_host(): accepts all valid IPs including
0.0.0.0 and :: (unlike is_valid_alias() which rejects unspecified addresses, since
those are not routable as client-facing URLs but are legitimate bind targets).

omlx/admin/routes.py — validate each comma-separated part of the host field on save,
returning a 400 with a readable message before an invalid value can cause a crash on restart.

Usage

Enter multiple bind addresses separated by commas in the Host field:

127.0.0.1, 0.0.0.0

Existing single-address settings and legacy YAML list values both continue to work without migration.

Testing

  1. Set host to 127.0.0.1, ::1 in the web UI and save — both addresses should appear in startup output
  2. Set host to a YAML list (host: [127.0.0.1]) and restart — web UI should show 127.0.0.1
  3. Enter an invalid value (e.g. not a host!!) — should get a readable 400 error, not [object Object]
  4. Single-address configs continue to work unchanged

🤖 Generated with Claude Code

fqx and others added 2 commits April 23, 2026 10:06
…display

When users manually set `host` to a YAML list in settings.yaml, the
backend would store the list object in ServerSettings.host (typed str),
causing the web UI to receive a non-string value. Alpine.js x-model
then displayed "[object Object]" in the host input, and saving triggered
a Pydantic 422 whose array-of-objects detail was joined to "[object Object]".

- settings.py: normalize host to string in from_dict() — list values are
  joined with ", " so the web UI can display and edit them normally
- dashboard.js: extract .msg from Pydantic error detail objects instead
  of calling .join() directly on them, preventing "[object Object]" in
  all error toasts (fixes two call sites)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Users can now enter multiple bind addresses in the host field separated
by commas (e.g. "127.0.0.1, 0.0.0.0"). The existing YAML list format
is also handled via the from_dict() normalization added in the previous
commit.

Changes:
- cli.py: split host string by comma before calling uvicorn.run(); print
  one URL line per address; asyncio.create_server() binds a socket for
  each host in the list natively
- utils/network.py: add is_valid_bind_host() which accepts all valid IPs
  (including 0.0.0.0 and ::) and hostnames — unlike is_valid_alias()
  which rejects unspecified addresses
- admin/routes.py: validate each comma-separated part of the host field
  on save so invalid values are rejected with a 400 before they can
  cause a crash on server restart

Backward-compatible: single-address strings and legacy YAML list values
both continue to work without any settings migration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant