Skip to content

chore: changed logging for actionRun to be user friendly#4076

Merged
Julusian merged 2 commits into
bitfocus:mainfrom
thedist:main
Apr 7, 2026
Merged

chore: changed logging for actionRun to be user friendly#4076
Julusian merged 2 commits into
bitfocus:mainfrom
thedist:main

Conversation

@thedist
Copy link
Copy Markdown
Member

@thedist thedist commented Apr 5, 2026

Currently with Companion API v2 and using an Expression on an action option the error shown to the user in their logs is somewhat generic and includes a stack trace that is not particularly useful to non-devs, such as:

26.04.05 14:50:19 Module: Error executing action: Error: Failed to parse action options. One or more options were invalid, Error: Failed to parse action options. One or more options were invalid
    at ConnectionChildHandlerNew.actionRun (./companion/dist/Instance/Connection/ChildHandlerNew.js:256:11)
    at #runAction (./companion/dist/Controls/ActionRunner.js:41:32)
    at ActionRunner.runMultipleActions (./companion/dist/Controls/ActionRunner.js:83:44)
    at ControlActionRunner.runActions (./companion/dist/Controls/ActionRunner.js:135:14)
    at runActionSet (./companion/dist/Controls/ControlTypes/Button/Base.js:253:26)
    at ControlButtonNormal.pressControl (./companion/dist/Controls/ControlTypes/Button/Base.js:277:21)
    at ControlStore.pressControl (./companion/dist/Controls/ControlStore.js:76:21)
    at #onDeviceClick (./companion/dist/Surface/Handler.js:356:36)
    at SurfacePluginPanel.emit (node:events:519:28)
    at SurfacePluginPanel.inputPress (./companion/dist/Surface/PluginPanel.js:279:14)

This PR hopes to improve on this by leaving the stack trace in the main Companion logger for debugging, but the message sent to the module log that will be seen by the users in the Companion WebUI will include the name of the action, the location, and the option errors.

26.04.05 14:53:02 Module: Error executing action: Failed to parse action options. One or more options were invalid
Action: Audio - Bus Mute - Location: Button 4/3/7 - Errors: {"value":"Value is not in the list of choices","functionID":"Value is not in the list of choices"}

Or if it happens in an Action that's on a Trigger instead of a Button

26.04.05 14:55:31 Module: Error executing action: Failed to parse action options. One or more options were invalid
Action: Util - Select Mix - Location: Trigger BY33SjlURn7h2FLnZjo1M - Errors: {"mix":"Value is not in the list of choices"}

This PR doesn't touch the error when an Expression is invalid when given by the Learn functionality on an action, partly because a lot of the values needed aren't currently provided to that function, but also because if the Learn function is providing invalid values then it's an issue for the module developer rather than the end user.

Summary by CodeRabbit

  • Bug Fixes
    • Error messages for failed action option parsing now include precise location details (e.g., trigger or specific button/page), making failures easier to identify.
    • Error handling/logging improved to forward only real error messages, reducing noise and improving diagnostic clarity.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dbf1b700-0e00-4466-a4a2-877e8cb76ebb

📥 Commits

Reviewing files that changed from the base of the PR and between 7556055 and 3496f0a.

📒 Files selected for processing (1)
  • companion/lib/Instance/Connection/ChildHandlerNew.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • companion/lib/Instance/Connection/ChildHandlerNew.ts

📝 Walkthrough

Walkthrough

ChildHandlerNew.ts updates refine error handling in actionRun: when parseEntityOptions fails it now constructs a precise location string from surface/button metadata (extras.surfaceId, or extras.controlId/extras.location with page/row/column) and throws an error including action label, location, and parse errors. The catch block now forwards only genuine Error instances and uses e.message.

Changes

Cohort / File(s) Summary
Action error construction & logging
companion/lib/Instance/Connection/ChildHandlerNew.ts
On failed parseEntityOptions, build a specific location (uses extras.surfaceId for trigger:*, or extras.controlId / extras.location plus pageNumber/row/column for bank/button cases) and throw an error containing Action: <label>, Location: <location>, and Errors: <JSON.stringify(optionErrors)>. In catch, only forward when the thrown value is an Error, using e.message rather than stringifying arbitrary values.

Poem

🎯 Action trips now tell us where,
Surface, control — they make it clear.
Errors trimmed to just the true,
Cleaner logs and kinder view. ✨

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: improving error logging for actionRun to be more user-friendly. It directly relates to the core objective of formatting module-visible errors for better readability.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thedist thedist marked this pull request as draft April 5, 2026 14:05
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
companion/lib/Instance/Connection/ChildHandlerNew.ts (1)

408-411: Nice approach filtering for Error instances! Small thought on the message formatting 💭

The instanceof Error check is a good call for cleaner user-facing logs. One tiny thing: since e.message is already a string, wrapping it in stringifyError() might be unnecessary. That said, if stringifyError does any additional sanitization you want, feel free to keep it!

♻️ Optional simplification
 			if (e instanceof Error) {
-				this.#sendToModuleLog('error', `Error executing action: ${stringifyError(e.message)}`)
+				this.#sendToModuleLog('error', `Error executing action: ${e.message}`)
 			}

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0c28ad17-52c7-45c3-9e03-2a65971abcc1

📥 Commits

Reviewing files that changed from the base of the PR and between 2eab6cb and 7556055.

📒 Files selected for processing (1)
  • companion/lib/Instance/Connection/ChildHandlerNew.ts

Comment thread companion/lib/Instance/Connection/ChildHandlerNew.ts
@thedist thedist marked this pull request as ready for review April 5, 2026 14:20
@Julusian Julusian merged commit 46f7357 into bitfocus:main Apr 7, 2026
8 checks passed
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.

2 participants