Skip to content

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

Closed
fqx wants to merge 2 commits into
jundot:mainfrom
fqx:fix/settings-host-list-type-coercion
Closed

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

Conversation

@fqx

@fqx fqx commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Superseded by a new PR that adapts to the uvicorn.Config + bind_socket() refactor introduced in #1526. The core logic is the same but the cli.py changes are rewritten to work with the new pre-bind approach.

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>
@fqx

fqx commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Summary

This PR enables users to specify multiple bind addresses directly from the web UI, rather than being limited to a single address or the catch-all 0.0.0.0.

Why it matters: Binding only to specific interfaces is more secure than listening on all interfaces. A common use case is exposing the server locally and over a private overlay network such as Tailscale, without opening it to every interface on the machine — for example:

127.0.0.1, 100.x.x.x

While this was already supported via manual edits to settings.yaml, the web UI could not round-trip a YAML list value — it would display [object Object] in the host field and produce an unreadable [object Object] error message when saving failed.

What changed:

  • settings.pyServerSettings.from_dict() now normalizes a YAML list into a comma-separated string, so the web UI always receives a plain string regardless of how the config file was written.
  • cli.py — the comma-separated host string is split before being passed to uvicorn.run(), which accepts a list of addresses and binds a socket for each.
  • network.py — adds is_valid_bind_host() to correctly accept unspecified addresses like 0.0.0.0 and :: as valid bind targets (which the existing is_valid_alias() rejects, since they are not routable as client-facing URLs).
  • admin/routes.py — validates each comma-separated entry on save and returns a readable 400 error before an invalid value can crash the server on restart.
  • admin/static/js/dashboard.js — extracts .msg from Pydantic error detail objects instead of joining the raw objects, fixing the [object Object] error display at two call sites.

Existing single-address configs and legacy YAML list values continue to work without any migration.

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