Skip to content

feat(settings): store user overrides in PostgreSQL - #758

Open
Ferryx349 wants to merge 4 commits into
mainfrom
feat/settings-db-overrides
Open

Ferryx349 wants to merge 4 commits into
mainfrom
feat/settings-db-overrides

Conversation

@Ferryx349

Copy link
Copy Markdown
Collaborator

Description

This PR adds settings_overrides table and SETTINGS_BACKEND=db opt-in so operator overrides live in the database instead of editable YAML files. Existing file overrides are imported on first bootstrap when the table is empty. Admin PATCH and restore save through a single async restore path.

Related Issue

Fixes :- #757

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

Add settings_overrides table and SETTINGS_BACKEND=db opt-in so operator
overrides live in the database instead of editable YAML files. Existing
file overrides are imported on first bootstrap when the table is empty.
Admin PATCH and restore save through a single async restore path.
@changeset-bot

changeset-bot Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a351a51

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls

coveralls commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 40061005497

Warning

No base build found for commit c40e570 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 75.154%

Details

  • Patch coverage: 81 uncovered changes across 5 files (106 of 187 lines covered, 56.68%).

Uncovered Changes

File Changed Covered %
src/utils/settings-store.ts 73 26 35.62%
src/utils/settings-config.ts 75 54 72.0%
src/index.ts 7 0 0.0%
src/cli/commands/config.ts 6 1 16.67%
src/utils/settings.ts 1 0 0.0%
Total (10 files) 187 106 56.68%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 11459
Covered Lines: 9001
Line Coverage: 78.55%
Relevant Branches: 5916
Covered Branches: 4057
Branch Coverage: 68.58%
Branches in Coverage %: Yes
Coverage Strength: 795.43 hits per line

💛 - Coveralls

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 1/5

[Medium impact] The changes reach settings storage and runtime configuration within a relay deployment.

This PR needs fixes before merging because notification overrides still fail to load, workers keep old settings, and config commands can stay open.

Findings

  1. P1 Config commands stay open ▶

Summary

This PR adds optional PostgreSQL storage for operator settings overrides.

  • Relay overrides can come from PostgreSQL when operators choose database mode.
  • Admin edits, CLI updates, and backup restores save through the selected settings backend.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Start[Process starts] --> Backend{Settings backend}
  Backend -->|file| Files[Read YAML overrides]
  Backend -->|db| Bootstrap[Load PostgreSQL overrides]
  Bootstrap --> Import[Import files when empty and unmarked]
  Import --> Cache[Cache overrides in this process]
  Edit[Admin edit or CLI change] --> Save[Save through selected backend]
  Save --> Backup[Back up nonempty database overrides]
  Backup --> Replace[Replace database rows]
  Replace --> Cache
  Replace --> Broadcast{Primary process?}
  Broadcast -->|Yes| Reload[Send reload messages to child workers]
  Broadcast -->|No| Local[No reload message sent]
Loading

Reviews (2) · Last reviewed commit: "fix(settings): address db override persi..." · Reviewed by Greptile

Comment thread src/repositories/settings-override-repository.ts Outdated
Comment thread src/utils/settings-config.ts
Comment thread src/utils/settings-config.ts
Comment thread src/utils/settings-store.ts
Comment thread src/utils/settings-config.ts
Comment thread src/utils/settings-config.ts
Comment thread src/utils/settings-store.ts
Comment thread src/utils/settings-store.ts Outdated
JSON-encode jsonb values, preserve dotted map keys and empty arrays, reload overrides across workers, route CLI and notifications through the db store, and backup before database replaces.
}

export const runConfigList = async (options: { json?: boolean } = {}): Promise<number> => {
await bootstrapSettingsStore()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Config commands stay open

With SETTINGS_BACKEND=db, the config commands now open the shared database pool but never close it. Returning from the command does not exit the CLI because the database connections remain open. With the default settings, commands wait for the 60-second idle timeout after printing their result. If DB_MIN_POOL_SIZE is above zero, they can remain open indefinitely.

Close the database client after each one-shot command, including error paths.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants