Skip to content

Remove throw reducers#626

Open
ryanbas21 wants to merge 4 commits intomainfrom
remove-throw-reducers
Open

Remove throw reducers#626
ryanbas21 wants to merge 4 commits intomainfrom
remove-throw-reducers

Conversation

@ryanbas21
Copy link
Copy Markdown
Collaborator

JIRA Ticket

N/A

Description

Remove throws from reducers, since they are impure. This is tricky because we have to determine what we want in state then. I opted for an unknown collector but im not positive of this its weird.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 6, 2026

⚠️ No Changeset found

Latest commit: 1781cf3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@ryanbas21 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 32 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 71250d9e-4ca9-4e6a-a86e-c4597929cfcd

📥 Commits

Reviewing files that changed from the base of the PR and between 44f9be3 and 1781cf3.

📒 Files selected for processing (5)
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/davinci-client/src/lib/client.store.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • packages/davinci-client/src/lib/node.reducer.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-throw-reducers

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.

ryanbas21 added 3 commits May 5, 2026 19:14
Add comprehensive test coverage for error handling in node.reducer for:
- NoValueCollector update rejection
- Undefined value detection
- Type validation for SingleValueCollector (must be string)
- MultiValueCollector object rejection
- PollingCollector update rejection

All tests fail as expected in RED phase (throws are unhandled by reducer).
…e writes

Eliminates thrown errors from updateCollectorValues — all validation failures
now write to collector.error instead, keeping Redux state predictable and
observable rather than blowing up the call stack.

Also adds an explicit PollingCollector type guard before the category branches
so that polling collectors (which are categorized as SingleValueAutoCollector)
are correctly rejected as read-only.
…update

Stale validation errors persisted in state after a user corrected their
input — a subsequent valid dispatch left the previous error message visible.
Mirror the pattern already used in pollCollectorValues by resetting
collector.error to null on every successful value-assignment path in
updateCollectorValues.
@ryanbas21 ryanbas21 force-pushed the remove-throw-reducers branch from fe20632 to 1e2483b Compare May 6, 2026 01:14
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 6, 2026

View your CI Pipeline Execution ↗ for commit 1e2483b

Command Status Duration Result
nx run-many -t build --no-agents ✅ Succeeded 3s View ↗
nx affected -t build lint test typecheck e2e-ci ✅ Succeeded 1m 48s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-06 01:28:55 UTC

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

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

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We updated the stale test "should throw with no collectors" to align with the PR's intent of replacing all reducer throws with state-based error writes. The test now verifies that an UnknownCollector is pushed into state with error: 'No collector found to update' instead of asserting the reducer throws, which it no longer does. This fix unblocks the failing @forgerock/davinci-client:test task.

Tip

We verified this fix by re-running @forgerock/davinci-client:test.

diff --git a/packages/davinci-client/src/lib/node.reducer.test.ts b/packages/davinci-client/src/lib/node.reducer.test.ts
index 51ac6f5..44d5159 100644
--- a/packages/davinci-client/src/lib/node.reducer.test.ts
+++ b/packages/davinci-client/src/lib/node.reducer.test.ts
@@ -344,7 +344,7 @@ describe('The node collector reducer', () => {
     ]);
   });
 
-  it('should throw with no collectors', () => {
+  it('should set error on UnknownCollector when no collector is found', () => {
     const action = {
       type: 'node/update',
       payload: {
@@ -372,7 +372,9 @@ describe('The node collector reducer', () => {
         },
       },
     ];
-    expect(() => nodeCollectorReducer(state, action)).toThrowError('No collector found to update');
+    const result = nodeCollectorReducer(state, action);
+    const unknownCollector = result.find((c) => c.id === 'submit-1');
+    expect(unknownCollector?.error).toBe('No collector found to update');
   });
 
   it('should set error on ActionCollector when update is attempted', () => {

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally AcI8-rIPR

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

@ryanbas21 ryanbas21 force-pushed the remove-throw-reducers branch from 1e2483b to 1781cf3 Compare May 6, 2026 01:25
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 6, 2026

Open in StackBlitz

@forgerock/davinci-client

pnpm add https://pkg.pr.new/@forgerock/davinci-client@626

@forgerock/device-client

pnpm add https://pkg.pr.new/@forgerock/device-client@626

@forgerock/journey-client

pnpm add https://pkg.pr.new/@forgerock/journey-client@626

@forgerock/oidc-client

pnpm add https://pkg.pr.new/@forgerock/oidc-client@626

@forgerock/protect

pnpm add https://pkg.pr.new/@forgerock/protect@626

@forgerock/sdk-types

pnpm add https://pkg.pr.new/@forgerock/sdk-types@626

@forgerock/sdk-utilities

pnpm add https://pkg.pr.new/@forgerock/sdk-utilities@626

@forgerock/iframe-manager

pnpm add https://pkg.pr.new/@forgerock/iframe-manager@626

@forgerock/sdk-logger

pnpm add https://pkg.pr.new/@forgerock/sdk-logger@626

@forgerock/sdk-oidc

pnpm add https://pkg.pr.new/@forgerock/sdk-oidc@626

@forgerock/sdk-request-middleware

pnpm add https://pkg.pr.new/@forgerock/sdk-request-middleware@626

@forgerock/storage

pnpm add https://pkg.pr.new/@forgerock/storage@626

commit: 1781cf3

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.24675% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.92%. Comparing base (5d6747a) to head (1781cf3).
⚠️ Report is 94 commits behind head on main.

Files with missing lines Patch % Lines
packages/davinci-client/src/lib/node.reducer.ts 54.66% 34 Missing ⚠️
packages/davinci-client/src/lib/client.store.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #626       +/-   ##
===========================================
- Coverage   70.90%   55.92%   -14.98%     
===========================================
  Files          53       22       -31     
  Lines        2021     2489      +468     
  Branches      377      358       -19     
===========================================
- Hits         1433     1392       -41     
- Misses        588     1097      +509     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/client.store.ts 0.30% <0.00%> (ø)
packages/davinci-client/src/lib/node.reducer.ts 72.10% <54.66%> (ø)

... and 72 files with indirect coverage changes

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Deployed 291fa9a to https://ForgeRock.github.io/ping-javascript-sdk/pr-626/291fa9adcf2e2cd2fc28f4e0fc44d78ba7b8bd8f branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔻 @forgerock/device-client - 0.0 KB (-10.0 KB, -100.0%)
🔻 @forgerock/journey-client - 0.0 KB (-91.9 KB, -100.0%)

📊 Minor Changes

📈 @forgerock/davinci-client - 48.9 KB (+0.0 KB)

➖ No Changes

@forgerock/device-client - 10.0 KB
@forgerock/oidc-client - 25.2 KB
@forgerock/sdk-utilities - 11.2 KB
@forgerock/sdk-types - 7.9 KB
@forgerock/protect - 144.6 KB
@forgerock/journey-client - 91.9 KB
@forgerock/storage - 1.5 KB
@forgerock/sdk-oidc - 4.8 KB
@forgerock/sdk-request-middleware - 4.5 KB
@forgerock/sdk-logger - 1.6 KB
@forgerock/iframe-manager - 2.4 KB


14 packages analyzed • Baseline from latest main build

Legend

🆕 New package
🔺 Size increased
🔻 Size decreased
➖ No change

ℹ️ How bundle sizes are calculated
  • Current Size: Total gzipped size of all files in the package's dist directory
  • Baseline: Comparison against the latest build from the main branch
  • Files included: All build outputs except source maps and TypeScript build cache
  • Exclusions: .map, .tsbuildinfo, and .d.ts.map files

🔄 Updated automatically on each push to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants