Skip to content

fix(serv): don't persist a legacy database block in sources mode (#601)#602

Open
amitdeshmukh wants to merge 1 commit into
masterfrom
fix/sources-config-persist-database-block
Open

fix(serv): don't persist a legacy database block in sources mode (#601)#602
amitdeshmukh wants to merge 1 commit into
masterfrom
fix/sources-config-persist-database-block

Conversation

@amitdeshmukh

Copy link
Copy Markdown
Collaborator

What

Fixes #601. In sources mode, a successful gj_config.update { mode: "apply" } wrote a config file that could not be reloaded.

saveConfigToDisk synced sources into viper and then called v.WriteConfig(), which serializes the entire viper tree — including the defaulted database.* keys (serv/config.go SetDefault) that were never in the on-disk config. The saved file then carried a spurious top-level database: block, and the next reload (reload_on_config_change) or restart rejected it via Config.validateIsSourcesUsed ("databases is legacy database-only config"), crash-looping the engine after any config apply. Even a minimal source_patches edit triggered it.

Fix

When IsSourcesUsed(), write a sanitized copy: drop the database/databases/metadata/catalog/filesystems/openapi keys from AllSettings() and WriteConfig through a fresh viper bound to the same file. A config written by gj_config.update now round-trips cleanly through a reload.

Test

Verified live against a sources-mode engine (reload_on_config_change: true): set_source_access (source_patches), register_source (update_sources), and add_role (roles) each preview→apply, the watcher reloads the saved file, and the engine stays up (health 200) with auth intact and the meta-source preserved — where before each apply FATAL'd on reload. The saved dev.yml no longer contains a top-level database: block.

In sources mode, saveConfigToDisk synced sources into viper and then called
v.WriteConfig(), which serializes the ENTIRE viper tree — including the
defaulted database.* keys (serv/config.go SetDefault) that were never in the
on-disk config. The written file then carried a top-level `database:` block,
and the next reload (reload_on_config_change) or restart rejected it via
Config.validateIsSourcesUsed ("databases is legacy database-only config"),
crash-looping the engine after any gj_config.update apply.

When IsSourcesUsed(), write a sanitized copy instead: drop the
database/databases/metadata/catalog/filesystems/openapi keys from
AllSettings() and WriteConfig through a fresh viper bound to the same file.
A config written by gj_config.update now round-trips cleanly through a reload.

Fixes #601.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Sources mode: gj_config.update apply persists a spurious top-level database: block that crash-loops the engine on reload

1 participant