core icon indicating copy to clipboard operation
core copied to clipboard

Monit Status widget shows [object Object] for service names since Monit 6.0.0 (CDATA in <name>)

Open adam8833 opened this issue 3 months ago • 2 comments

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

  • [x] I have read the contributing guidelines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
  • [x] I am convinced that my issue is new after having checked both open and closed issues at https://github.com/opnsense/core/issues?q=is%3Aissue
  • [x] AI tools were used to create at least part of the text submitted herewith.

If AI was used, please disclose:

  • Model used: Claude (Sonnet 5, via Claude Code)
  • Extent of AI involvement: AI diagnosed the root cause via live reproduction on my OPNsense box (confirmed the XML/JSON shape difference through the actual StatusController.php parse path) and drafted this report; I reviewed and approved the content before submitting.

Describe the bug

On the Lobby dashboard, the "Monit Status" widget renders every service/check as the literal string [object Object], though the status indicator dot next to each entry is still correct (green/red). This started after upgrading to OPNsense 26.7.3, which bundles Monit 6.0.0 (up from 5.35.2).

To Reproduce

Steps to reproduce the behavior:

  1. Upgrade to OPNsense 26.7.3 (Monit 6.0.0)
  2. Have any Monit checks configured (stock or custom)
  3. View the "Monit Status" widget on the Lobby dashboard
  4. Every service name renders as [object Object]

Expected behavior

The widget should display the actual service/check name for each entry, as it did under Monit 5.35.2.

Describe alternatives you considered

N/A - this is a straightforward parser bug with a one-line fix (see Additional context below).

Screenshots

(attached below)

Relevant log files

N/A - not a runtime error, reproducible directly from Monit's own status XML output (see Additional context).

Additional context

Root cause: Monit 6.0.0 changed how service names are emitted in its status XML - they're now wrapped in CDATA:

<name><![CDATA[RootFs]]></name>

Monit 5.35.2 emitted plain text: <name>RootFs</name>.

OPNsense/Monit/Api/StatusController.php (line ~85) parses the response with:

simplexml_load_string($response)

without the LIBXML_NOCDATA flag. Without that flag, CDATA content is dropped when the SimpleXMLElement is later json_encode'd - name serializes to {} instead of the string. The frontend widget (www/js/widgets/Monit.js) then renders that empty object directly, producing [object Object].

Reproduction (verified locally), feeding both XML shapes through the same parse path:

CDATA input          -> {"service":{"@attributes":{"type":"5"},"name":{},"status":"0"}}
plain input          -> {"service":{"@attributes":{"type":"5"},"name":"RootFs","status":"0"}}
with LIBXML_NOCDATA  -> {"service":{"@attributes":{"type":"5"},"name":"RootFs","status":"0"}}

Suggested fix: add LIBXML_NOCDATA to the simplexml_load_string() call in StatusController.php.

Impact: cosmetic only - underlying Monit checks and alerting are unaffected, only the dashboard widget's display of service names is broken.

Environment

Software version used and hardware type if relevant, e.g.:

OPNsense 26.7.3 (amd64) FreeBSD 15.1-RELEASE-p3 Monit 6.0.0 (upgraded from 5.35.2 in this release)

Image

adam8833 avatar Aug 27 '26 16:08 adam8833

can install https://github.com/opnsense/core/commit/d678d9d4c36691b13deb769dd97b3939ac99086f via:

# opnsense-patch d678d9d

fichtner avatar Aug 28 '26 08:08 fichtner

26.7.3_8: Fixed it.

Thanks

f45tb00t avatar Aug 28 '26 13:08 f45tb00t