Show specific error dialog when task lock fails due to mapping level or team membership - #7282
Open
jaroslav-kubicek wants to merge 1 commit into
Conversation
…evel or team membership The lock-for-mapping/lock-for-validation catch-all branches leaked raw Python enum reprs (e.g. MappingNotAllowed.USER_NOT_CORRECT_MAPPING_LEVEL) as SubCodes, which no frontend message key matches, so users always got the generic 'It wasn't possible to lock this task for you...' dialog. Backend now emits clean per-reason SubCodes (UserNotCorrectMappingLevel, UserNotTeamMember) following the existing convention, and fixes the ValidtionNotAllowed typo in the validation fallback. Frontend adds the matching i18n messages so LockError resolves them automatically, and drops a stray debug console.log in the error handler. Fixes hotosm#7281 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
7 tasks
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.



Closes #7281
What
When locking a task for mapping/validation fails because of the user's experience level or team membership, the UI now shows a specific explanation instead of the generic "It wasn't possible to lock this task for you… Check if your user matches the level, role and permissions required by this project."
Why
The frontend
LockErrorcomponent already resolves per-reason messages by SubCode (works forUserNotAllowed,ProjectNotPublished,InvalidTaskState, …), but the backend catch-all branches leaked raw Python enum reprs as SubCodes — e.g.MappingNotAllowed.USER_NOT_CORRECT_MAPPING_LEVEL— which no message key matches, so the generic fallback always rendered. #2191 fixed the backend half of this in 2020 (proper 403 + SubCode instead of a 500); this completes the frontend half and cleans up the SubCodes.Changes
Backend
mapping_service.py: explicit branches forUSER_NOT_CORRECT_MAPPING_LEVEL→UserNotCorrectMappingLevelandUSER_NOT_TEAM_MEMBER→UserNotTeamMember; defensive fallback now uses a cleanMappingNotAllowedprefix instead of the enum repr.validator_service.py: same two branches; fallback renamedValidtionNotAllowed→ValidationNotAllowed(typo fix). The old subcode collapsed all remaining validation reasons into one string, so they were indistinguishable client-side.Frontend
taskSelection/messages.js+locales/en.json: new messages forUserNotCorrectMappingLevel,UserNotTeamMember, and theMappingNotAllowed/ValidationNotAllowedfallbacks — picked up automatically by the existingmessages[\${error}Error`]lookup inLockError`.utils/promise.js: removed a stray debugconsole.loginhandleErrors.