Skip to content

settings-sync: handle missing /ubus endpoint instead of parsing 404 HTML as JSON #70

Description

@ang3el7z

Environment

  • Proton2025 v1.3.0
  • OpenWrt router with luci-theme-proton2025, luci-base, rpcd, rpcd-mod-luci, and uhttpd installed

Problem

After opening LuCI, the browser console reports:

[Proton2025] Failed to sync from UCI: SyntaxError: Unexpected token "<", "<h1>Not Fo"... is not valid JSON

The error originates from settings-sync.js in syncFromUci(). The script calls response.json() without checking the HTTP response.

Investigation

The RPC object itself is available and works locally:

ubus list luci.proton-settings
ubus call luci.proton-settings getSettings

Both commands succeed; getSettings returns the expected settings object.

However, the HTTP endpoints used by settings-sync.js are unavailable on this router:

curl -i -H "Content-Type: application/json" --data "{}" http://ROUTER/ubus
curl -i -H "Content-Type: application/json" --data "{}" http://ROUTER/ubus/

Both return:

HTTP/1.1 404 Not Found
Content-Type: text/html

<h1>Not Found</h1>

The installed uhttpd configuration has no ubus_prefix or ubus socket configuration, and no HTTP ubus gateway module is installed.

Expected behavior

  1. Theme installation should either ensure the HTTP ubus gateway required by settings-sync.js is available/configured, or use the supported LuCI RPC path for the target OpenWrt release.
  2. settings-sync.js should check response.ok and the response content type before calling response.json(), then log a clear actionable error instead of a JSON SyntaxError.

This does not affect the theme RPC backend itself; it only breaks browser-to-UCI synchronization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions