Title: fix(settings): report a failed settings write instead of reporting success by waleedlatif1 · Pull Request #7023 · simstudioai/sim · GitHub
Open Graph Title: fix(settings): report a failed settings write instead of reporting success by waleedlatif1 · Pull Request #7023 · simstudioai/sim
X Title: fix(settings): report a failed settings write instead of reporting success by waleedlatif1 · Pull Request #7023 · simstudioai/sim
Description: The route cannot fail app/api/users/me/settings/route.ts:75 } catch (error: any) { logger.error(`[${requestId}] Settings update error`, error) return NextResponse.json({ success: true }, { status: 200 }) } A failed upsert is answered exactly like a successful one. Which makes the client's rollback unreachable useUpdateGeneralSetting (hooks/queries/general-settings.ts:166) is a full optimistic mutation: onMutate writes the new value into the cache and calls syncThemeToNextThemes onError restores context.previousSettings and re-syncs the theme requestJson throws ApiClientError only on a non-2xx. Since the route always answered 200, onError could never run — the rollback and its theme re-sync are dead code. What the user sees The upsert throws (pool exhaustion, a conflict on settings.userId, a replica failover). The UI applies the change. Nothing is persisted. onSettled invalidates, the refetch returns the old value, and the setting quietly reverts with no error anywhere. For a consent-shaped setting — telemetry, email opt-out — the user believes they opted out and did not. The fix The catch returns 500, which is what the mutation was already written to handle. No client change needed. Deliberately not changed GET still falls back to defaultUserSettings on error, also at 200. Failing it would take the settings page down on a transient read, and whether that trade is right is a separate judgement from this one. Worth noting it compounds the above — a failing GET makes the post-write refetch show defaults — but the write path is the one making a false claim. Testing A route test drives the failure through the real handler rather than asserting on a mock: ✓ reports success when the write lands ✓ reports failure when the write throws Verified it can fail — restoring the 200 turns the second case red with expected 200 to be 500. bun run type-check clean; 41 tests passing across app/api/users and the settings hook.
Open Graph Description: The route cannot fail app/api/users/me/settings/route.ts:75 } catch (error: any) { logger.error(`[${requestId}] Settings update error`, error) return NextResponse.json({ success: true }, { stat...
X Description: The route cannot fail app/api/users/me/settings/route.ts:75 } catch (error: any) { logger.error(`[${requestId}] Settings update error`, error) return NextResponse.json({ success: true }, { stat...
Opengraph URL: https://github.com/simstudioai/sim/pull/7023
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8c5fbadf-3119-b5d8-c7de-f2d317783c95 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 90F6:1BB96C:10351AC:162CBF1:6AFB646A |
| html-safe-nonce | 25c09618f442c043e00a7d1057fe3bf156ce20f51103a4fb72726d24bd1a981b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MEY2OjFCQjk2QzoxMDM1MUFDOjE2MkNCRjE6NkFGQjY0NkEiLCJ2aXNpdG9yX2lkIjoiMTgxODg5NjU5Njk5Mzc5NTE3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7b77a563c1a2074098aa1a84bbe3366f3e882ef2c8a17578f0266300c0ed10da |
| hovercard-subject-tag | pull_request:4344737153 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/7023/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | The route cannot fail app/api/users/me/settings/route.ts:75 } catch (error: any) { logger.error(`[${requestId}] Settings update error`, error) return NextResponse.json({ success: true }, { stat... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width