fix(common): make ResultType.mapError invoke its callback - #118
Merged
Merged
Conversation
mapError returned TError(e.error) without calling the callback, so AuthCubit's `..mapError((f) => isError(f))` never ran and a failed login/sign-up left the cubit in RLoading forever. The callback now runs; an Exception it returns replaces the error, anything else keeps the original. Adds the first unit tests for common (ResultType) and registers modules/common/test in sonar.tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
tarruk
self-requested a review
September 22, 2026 19:50
tarruk
approved these changes
Sep 22, 2026
amaury901130
added a commit
that referenced
this pull request
Sep 22, 2026
- known-issues: mark #1 and #5 resolved, narrow #2 to the remaining env layout drift, update #3/#13 for the new common and domain tests - overview, CLAUDE.md, feature guide: drop the mapError warning, describe the API_URL fallback - testing, bootstrap customization: current test dirs and sonar.tests Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ResultType.mapError(modules/common/lib/core/result_type.dart) returnedTError(e.error)without calling the callback.AuthCubit.loginandsignUphandle results like this:So on a
TError, nothing was emitted and the cubit stayed inRLoadingforever: the button kept spinning and no error was shown. The bug is hidden today only because the exampleAuthRepositoryImplalways succeeds. It surfaces as soon as a real backend returns an error.Fix:
mapErrornow calls the callback. If the callback returns anException, that replaces the error (transform semantics); anything else keeps the original error (side-effect semantics, asAuthCubituses it).TSuccessis unaffected.Also:
modules/common/test/core/result_type_test.dart, the first tests incommon, coveringmapErrorandmapSuccess.modules/common/testtosonar.tests.Issue
known-issues #1 in #117.
Preview
N/A
Notes:
cd modules/common && flutter pub get && flutter testandmelos analyzebefore merging.result_type.dartorsonar-project.properties.docs/architecture/known-issues.md, and themapErrorwarnings inCLAUDE.mdrule 3 andfeature-guide.md(docs: add CLAUDE.md and architecture/development docs #117).🤖 Generated with Claude Code