refactor(storage): extract parseJsonColumn helper in organization-settings - #6493
Merged
pedrofrxncx merged 1 commit intoAug 25, 2026
Merged
Conversation
…tings The get() method had the same 'string or already-parsed jsonb column' ternary inlined 7 times, one per settings field. Collapse it into one generic helper and call it per field with an explicit type argument (kysely's ColumnType select type doesn't infer cleanly through a bare generic, so the type argument is spelled out at each call site).
pedrofrxncx
deleted the
refactor/dedupe-org-settings-json-column-parse-w2
branch
August 25, 2026 02:02
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.
Source: C1 code-reduction, found while auditing the org-settings storage layer (
apps/api/src/storage/organization-settings.ts) for the org-settings-persistence focus area. No related open PR touches this file — #6487/#6481/#6464/#6445 (recently merged/open) all touchupdate.ts/delete.ts/member-list.ts, not this file.What/why:
OrganizationSettingsStorage.get()inlined the same 'jsonb column may come back as a string or as an already-parsed value' ternary 7 times, once per settings field (sidebar_items,enabled_plugins,registry_config,simple_mode,default_home_agents,flags,sprint_config). Collapsed into oneparseJsonColumn<T>()helper called per field. A maintainer gets one place to fix this normalization logic instead of seven.Net delta: -35 / +28 lines in one file, no behavior change: same null-check, same
typeof === "string" ? JSON.parse(...) : valuelogic, just factored out. Each call site passes an explicit type argument because Kysely'sColumnTypeselect type doesn't infer cleanly through a bare generic parameter (confirmed viatsc --noEmit— inferring from the parameter directly produced aT[][]mismatch).How a reviewer confirms: read the diff —
parseJsonColumnis a straight extraction of the pre-existing ternary, and every field still round-trips through it. No integration test exists for this file that doesn't need real Postgres (this box has none available), so verification here is static: the change is a pure refactor with no schema/query changes.Checks run locally:
bun run fmt,cd apps/api && bunx tsc --noEmit(green),bunx oxlint apps/api/src/storage/organization-settings.ts(0 warnings/errors). Full CI (including the Postgres-backed integration test for this file) validates the rest.Summary by cubic
Deduplicates JSON parsing for organization settings by extracting a
parseJsonColumn<T>()helper. Behavior is unchanged: the previous per-field ternary becomes a single helper that normalizes string-or-objectjsonbvalues with the same null check.get()inapps/api/src/storage/organization-settings.tsis touched.kyselyselect type inference limits.sidebar_items,enabled_plugins,registry_config,simple_mode,default_home_agents,flags,sprint_config) route through it.Written for commit 1bec1b4. Summary will update on new commits.