Skip to content

fix(client): dispatch error actions in settings sagas - #71754

Open
venkatsammm wants to merge 2 commits into
freeCodeCamp:mainfrom
venkatsammm:fix/settings-sagas-error-actions
Open

venkatsammm wants to merge 2 commits into
freeCodeCamp:mainfrom
venkatsammm:fix/settings-sagas-error-actions

Conversation

@venkatsammm

@venkatsammm venkatsammm commented Nov 21, 2026 •

Copy link
Copy Markdown

Checklist:

Closes #71585

Summary

11 catch blocks in client/src/redux/settings/settings-sagas.js yielded the
error action creator instead of invoking it:

} catch {
  yield put(updateMySocialsError);
}

put with a bare function reference never dispatches an error action, so
failed settings requests (socials, portfolio, keyboard shortcuts, etc.) failed
silently: no flash message, and Redux stayed out of sync with the server. The
global handler in client/src/redux/error-saga.js only reacts to actions whose
payload is an error, so these failures were dropped entirely.

The regression was introduced by the unused-variable cleanup in 5ef9868, which
removed the unused (e) parameter from the catch clauses.

Changes

  • Invoke the error action with the caught error in all 11 catch blocks:
    yield put(xxxError(e)).
  • Export the individual saga functions so they can be unit tested.
  • Add settings-sagas.test.js covering every affected saga with
    redux-saga-test-plan, asserting the invoked error action is yielded when
    the request (or the store write) throws.

Test plan

  • pnpm --filter @freecodecamp/client exec vitest run src/redux/settings — 12 tests pass (11 new).
  • pnpm --filter @freecodecamp/client exec oxlint --deny-warnings on both files — clean.
  • prettier --check on both files.
    Checklist:

Closes #71585

Summary

11 catch blocks in client/src/redux/settings/settings-sagas.js yielded the
error action creator instead of invoking it:

} catch {
  yield put(updateMySocialsError);
}

put with a bare function reference never dispatches an error action, so
failed settings requests (socials, portfolio, keyboard shortcuts, etc.) failed
silently: no flash message, and Redux stayed out of sync with the server. The
global handler in client/src/redux/error-saga.js only reacts to actions whose
payload is an error, so these failures were dropped entirely.

The regression was introduced by the unused-variable cleanup in 5ef9868, which
removed the unused (e) parameter from the catch clauses.

Changes

  • Invoke the error action with the caught error in all 11 catch blocks:
    yield put(xxxError(e)).
  • Export the individual saga functions so they can be unit tested.
  • Add settings-sagas.test.js covering every affected saga with
    redux-saga-test-plan, asserting the invoked error action is yielded when
    the request (or the store write) throws.

Test plan

  • pnpm --filter @freecodecamp/client exec vitest run src/redux/settings — 12 tests pass (11 new).
  • pnpm --filter @freecodecamp/client exec oxlint --deny-warnings on both files — clean.
  • prettier --check on both files.

@venkatsammm
venkatsammm requested a review from a team as a code owner November 21, 2026 05:34
@github-actions github-actions Bot added platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there,

Thanks for opening this pull request.

The automated checks found some issues:

Checklist: The PR description is missing the required checklist or some of its items are not completed:

  1. The Checklist: heading is present in the PR description.
  2. The checkbox items are ticked (changed from [ ] to [x]).
  3. You have actually completed the items in the checklist.

Please edit your PR description to include the following template with the checklist items completed.

Checklist:

<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. -->

- [ ] I have read and followed the [contribution guidelines](https://contribute.freecodecamp.org).
- [ ] I have read and followed the [how to open a pull request guide](https://contribute.freecodecamp.org/how-to-open-a-pull-request/).
- [ ] My pull request targets the `main` branch of freeCodeCamp.
- [ ] I have tested these changes either locally on my machine, or GitHub Codespaces.

<!--If your pull request closes a GitHub issue, replace the XXXXX below with the issue number.-->

Closes #XXXXX

<!-- Feel free to add any additional description of changes below this line -->

Join us in our chat room or our forum if you have any questions or need help with contributing.

@github-actions github-actions Bot removed the deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. label Nov 21, 2026
@huyenltnguyen

Copy link
Copy Markdown
Member

Hi there, thank you for your interest in contributing.

However, the linked issue hasn't been triaged yet, so I'm closing this PR to keep the queue manageable.

Feel free to open a new PR once consensus has been reached and the issue is marked as ready for contribution.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 21, 2026
@Sembauke

Copy link
Copy Markdown
Member

Thanks for covering all eleven affected handlers. Could you also add one integration regression test for a representative setting, such as updating socials?

Dispatch the settings-update action through a Redux store with the application's middleware order (including thunk and saga) and the shared error saga. Mock the API call to reject with an Error, then assert that:

  • The corresponding error action reaches the store with the original error as its payload.
  • The flash state contains the generic error message (flash.generic-error).

The test should fail with the original put(updateMySocialsError) and pass with put(updateMySocialsError(error)). The existing generator tests cover the individual handlers; this additional test would verify that the failure actually reaches the shared notification path. One representative integration test should be enough.

@Sembauke Sembauke reopened this Nov 24, 2026
@freeCodeCamp freeCodeCamp unlocked this conversation Nov 27, 2026

This branch has not been deployed

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

Labels

platform: learn UI side of the client application that needs familiarity with React, Gatsby etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Settings sagas silently drop errors on failure

3 participants