Skip to content

Handle external-state plugin errors with ErrorController#868

Merged
KVSRoyal merged 18 commits into
player-1-dot-zerofrom
external-action-error
Jun 3, 2026
Merged

Handle external-state plugin errors with ErrorController#868
KVSRoyal merged 18 commits into
player-1-dot-zerofrom
external-action-error

Conversation

@KVSRoyal

Copy link
Copy Markdown
Member

Now that ErrorController is available, we use that to handle errors from the external-state plugin instead of letting it fall through. See included docs updates for more details.

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major
  • N/A. Part of 1.0

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 382.95kB (8.0%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
plugins/check-path/core 442.6kB 41 bytes (0.01%) ⬆️
plugins/async-node/core 504.25kB 41 bytes (0.01%) ⬆️
plugins/markdown/core 683.26kB 41 bytes (0.01%) ⬆️
plugins/asset-transform/core 11.25kB 3.34kB (42.22%) ⬆️⚠️
plugins/reference-assets/core 554.9kB 41 bytes (0.01%) ⬆️
plugins/beacon/core 424.2kB 41 bytes (0.01%) ⬆️
plugins/metrics/core 460.76kB 41 bytes (0.01%) ⬆️
core/player 1.02MB 146 bytes (0.01%) ⬆️
plugins/external-state/core 426.87kB 379.22kB (795.79%) ⬆️⚠️

Affected Assets, Files, and Routes:

view changes for bundle: plugins/async-node/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
AsyncNodePlugin.native.js 41 bytes 441.63kB 0.01%
view changes for bundle: plugins/beacon/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
BeaconPlugin.native.js 41 bytes 409.73kB 0.01%
view changes for bundle: plugins/asset-transform/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.legacy-esm.js 3.34kB 3.34kB 100.0% ⚠️
view changes for bundle: core/player

Assets Changed:

Asset Name Size Change Total Size Change (%)
Player.native.js 41 bytes 426.34kB 0.01%
cjs/index.cjs 35 bytes 202.28kB 0.02%
index.legacy-esm.js 35 bytes 195.55kB 0.02%
index.mjs 35 bytes 195.55kB 0.02%
view changes for bundle: plugins/external-state/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ExternalStatePlugin.native.js 373.57kB 407.9kB 1088.21% ⚠️
cjs/index.cjs 1.92kB 7.08kB 37.3% ⚠️
index.legacy-esm.js 1.86kB 5.94kB 45.54% ⚠️
index.mjs 1.86kB 5.94kB 45.54% ⚠️
view changes for bundle: plugins/reference-assets/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ReferenceAssetsPlugin.native.js 41 bytes 516.92kB 0.01%
view changes for bundle: plugins/markdown/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MarkdownPlugin.native.js 41 bytes 658.11kB 0.01%
view changes for bundle: plugins/metrics/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MetricsPlugin.native.js 41 bytes 428.42kB 0.01%
view changes for bundle: plugins/check-path/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
CheckPathPlugin.native.js 41 bytes 413.12kB 0.01%

@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (30198e7) to head (eb34b91).

Additional details and impacted files
@@           Coverage Diff            @@
##   player-1-dot-zero   #868   +/-   ##
========================================
========================================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KVSRoyal KVSRoyal marked this pull request as ready for review May 16, 2026 03:17
@KVSRoyal KVSRoyal requested review from a team as code owners May 16, 2026 03:17

test("no handler registered for external state - no transition occurs", async () => {
// Create a player with NO handlers registered
test("no handler registered for external state - calls captureError with ExternalStateError", async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we get some tests to validate how you'd handle this error by the error controller? My understanding is there are two ways, one via content and another by tapping onError. I think these tests would be valid for each platform, at least the onError ones since external actions are closer to integrations.

this.errorController?.captureError(
ExternalStateError.missingTransitionValue(toState.value.ref),
);
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How should the error be handled if we there isn't an errorController? Right now it'd fail silently potentially leaving the user stuck with a blank or stale screen. It'd likely be worth logging up front so that integrators know when this happens, or maybe a check at the start to ensure we have what we need to continue, like the InProgress state check below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Adding

extends Error
implements PlayerErrorMetadata<ExternalStateErrorMetadata>
{
readonly type: string = "EXTERNAL-STATE";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we follow the same convention for types as the primary type definition, i.e. lowercase?

extends Error
implements PlayerErrorMetadata<ExternalStateErrorMetadata>
{
readonly type: string = "externalState";

@JunDangIntuit JunDangIntuit May 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May we add this to ErrorTypes so it's the single source of truth. for example: export const ErrorTypes = {
EXTERNAL_STATE: "externalState",
}
Drop the : string annotation: readonly type = ErrorTypes.EXTERNAL_STATE. Since ErrorTypes is as const, the field infers the literal "external-state". Because string widens it and breaks narrowing — TS can't tell this error apart from others whose type is also typed as string.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do! Good call

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Er, except I probably will keep string since that's the pattern used in other places.

@KVSRoyal KVSRoyal requested review from a team as code owners May 26, 2026 16:21
@KVSRoyal KVSRoyal force-pushed the external-action-error branch from 3f7a804 to 3a9f697 Compare May 26, 2026 16:52
Comment thread .circleci/config.yml Outdated
@TestTemplate
fun testMissingHandlerNavigatesViaContentErrorTransitions() = runBlockingTest {
val plugin = ExternalStatePlugin(
ExternalStateHandler(ref = "different-ref") { _, _, transition ->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmmmm is having no handler expected to go into an error state? Do we not get a bunch of no-ops if there's no handler found for the ref in the registry? Could you show me where it errors out

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi! It goes into an error state, yeah. Here is where the core code errors out.

@KVSRoyal KVSRoyal requested a review from brocollie08 May 28, 2026 22:18
@KVSRoyal KVSRoyal merged commit 9aa8a41 into player-1-dot-zero Jun 3, 2026
19 checks passed
@KVSRoyal KVSRoyal deleted the external-action-error branch June 3, 2026 22:55
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.

4 participants