Fix self-host daemon setup URLs (MUL-2804)#3474
Conversation
|
@barbudour is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
Bohan-J
left a comment
There was a problem hiding this comment.
Request changes
The core fix is well-aimed — self-host operators should see a setup command pointing at their own instance (multica setup self-host --server-url … --app-url …), and Multica Cloud defaults should stay untouched (which they do, verified byte-for-byte). A few things should be resolved before this lands.
Blocking
1. Split out the unrelated Fix hook dependency warnings commit (482e636f).
That commit touches 7 files that have nothing to do with self-host setup URLs — auth-initializer.tsx, attachment-preview-modal.tsx, search-command.tsx, step-runtime-connect.tsx, activity-heatmap.tsx, usage-section.tsx. These span auth bootstrap, search memoization, attachment preview, onboarding analytics, and usage/cost chart recomputation. Even where a change is individually correct, it shouldn't ride along in a feature PR — most notably the auth-initializer.tsx effect going from [] to a six-element dependency array, which changes when the auth bootstrap effect re-runs and deserves its own focused review. Please move the lint/hook cleanup into a dedicated PR so it can be reviewed and tested on its own.
2. FRONTEND_ORIGIN-only deployments still render the Cloud command.
In daemonSetupURLsFromEnv() (server/internal/handler/config.go), FRONTEND_ORIGIN is only consulted as an app-URL fallback inside the if appURL == "" && serverURL != "" branch. If an operator sets only FRONTEND_ORIGIN (with MULTICA_APP_URL and MULTICA_PUBLIC_URL unset), serverURL == "" so that branch is skipped, appURL stays empty, and the function returns "", "" → the dialog falls back to the Cloud command. But the docs mark FRONTEND_ORIGIN as the variable self-host must set (environment-variables.mdx), so a bare-binary / systemd deployment following the required-vars docs still reproduces #3013. Please make FRONTEND_ORIGIN an unconditional appURL fallback (not gated on MULTICA_PUBLIC_URL being set), let serverURL fall back to appURL for the same-origin case, and add a Go test for the FRONTEND_ORIGIN-only config.
3. The new /api/config fields bypass the response-schema rule.
getConfig() in packages/core/api/client.ts is a bare return this.fetch("/api/config"), and the two new fields (daemon_server_url / daemon_app_url) flow straight into a rendered shell command. If a server or proxy returns a non-string for one of them, normalizeCommandURL's .trim() in connect-remote-dialog.tsx throws and takes down the dialog render. The repo's API Response Compatibility guidance asks endpoint responses to go through parseWithFallback with a malformed-response test. Please add a lenient schema + a malformed-response test for the config endpoint, or have a maintainer explicitly mark /api/config as exempt — this PR shouldn't silently widen the unvalidated surface.
Should-fix (can be follow-ups once the above are addressed)
urlHostEquals()is fail-open for scheme-less hosts,host:port, and trailing-dot forms:url.Parse("api.multica.ai").Hostname()is"", and"api.multica.ai:8080"parses with an empty host, soisOfficialCloudDaemonConfigreturns false and the official-cloud suppression is bypassed. Canonicalize the host (e.g. re-parse with a synthetic scheme whenHostname()is empty, and trim a trailing dot) before the allowlist comparison, and add table-driven tests for bare-host /host:port/ trailing-dot.- Chinese docs not synced. The English
environment-variables.mdxgainedMULTICA_APP_URL/MULTICA_PUBLIC_URLrows; the Chinese pageenvironment-variables.zh.mdxstill lacks them.
Thanks for the work on this — the backend/frontend wiring and the dialog tests are solid; it mainly needs the scope trimmed and the two correctness gaps closed.
482e636 to
8155da4
Compare
|
Addressed the review feedback in 8155da4:
Validation run locally:
|
Summary
/api/configat runtimemultica setup self-host --server-url ... --app-url ...in the Add computer dialogFixes #3013.
Testing
go test ./internal/handler -run 'TestGetConfig'fromserver/git diff --checkNotes
ERR_PNPM_ENOSPC).