Repository navigation
fix(settings): report a fully denied Settings Save as one failure - #1355
Conversation
…t 17 Since LeanerCloud#614 gated per-service config PUTs on unrestricted account scope, a scoped admin's Save fires all 17 service PUTs and every one returns 403. Promise.allSettled kept the save going, and the toast read "Settings saved, but 17 services failed: <same denial x17>" even though nothing was saved. Only say "Settings saved, but ..." when something did save (the global PUT went out or at least one service PUT succeeded). When nothing saved and every service PUT was permission-denied, show the backend's single reason in the same "Failed to save settings: permission denied: ..." form the global PUT already uses. When nothing saved for other reasons, say the save failed and list the services. The dirty-snapshot handling is unchanged: failed services keep their fields dirty for a retry. Refs LeanerCloud#617 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50. Or wait 59 minutes for your next included review. View limit details
Comment |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): APPROVE Blocking:
|
|
Local verification at
|
|
Marked ready and merged by IAmJSD's agent, at IAmJSD's request (IAmJSD reviewed the before/after screenshots; cristim is traveling), after the independent review and local verification above, all at |
Since #614, the per-service config PUTs need unrestricted account scope, like the global config PUT. A scoped admin can still click Save, which fires all 17 service PUTs; every one returns 403, and the toast read "Settings saved, but 17 services failed:" followed by the same denial 17 times, even though nothing was saved. This PR shows one "Failed to save settings: permission denied: ..." toast in that case, and only says "Settings saved, but ..." when something actually saved.
Closes #617
What changed
frontend/src/settings.ts:saveGlobalSettingsrecords whether the global PUT was sent (globalSent), and the failure toast text now comes from a new helper,serviceSaveFailureMessage:isPermissionDeniedError: "Failed to save settings: ", the same wording as a global-PUT 403.frontend/src/__tests__/settings-service-payment.test.ts.Why this approach
The issue offers three options. Mapping permission-denied results to one failure toast is the smallest change and leaves the save and dirty-tracking flow alone. Skipping unchanged service PUTs would change what Save writes, which interacts with coverage propagation and the #539 stale-write handling (and the existing test pins 17 calls). Hiding or disabling settings for scoped users would need the session to expose account scope, which the frontend can't see today. The extra "nothing saved, other errors" branch fixes the same false "Settings saved" claim for non-permission failures.
Screenshots
Before is main (
a14dc8f2), after is this branch. Both are headless Chromium at 1440x900 against the repo's mocked e2e API. The scenario is Admin > Purchasing policies with every config PUT mocked to 403, after changing the EC2 payment and clicking Save.Verification
Run on this branch's head
a89a19cdon top of maina14dc8f2:a14dc8f2and pass here. Randomized run: 18/18.Notes for review
/auth/me).Overlaps
Other branches edit
settings.tsin different regions only (#186 near line 3170, #734 near lines 1348-1509, #731, #728, #748), so no textual conflicts with thesaveGlobalSettingshunk (about lines 3550-3700) are expected. #642 also editssettings.tsaround Reset/reload and should be checked when combining. Those PRs will be opened alongside this one and merged in sequence, with conflicts resolved on the later branch.Note for the UI owner
This changes UI code that @cristim owns. IAmJSD reviewed the before/after screenshots and asked for it to be merged; any design point you disagree with can be a follow-up.
🤖 Generated with Claude Code