fix(serv): don't persist a legacy database block in sources mode (#601)#602
Open
amitdeshmukh wants to merge 1 commit into
Open
fix(serv): don't persist a legacy database block in sources mode (#601)#602amitdeshmukh wants to merge 1 commit into
amitdeshmukh wants to merge 1 commit into
Conversation
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>
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.
What
Fixes #601. In sources mode, a successful
gj_config.update { mode: "apply" }wrote a config file that could not be reloaded.saveConfigToDisksynced sources into viper and then calledv.WriteConfig(), which serializes the entire viper tree — including the defaulteddatabase.*keys (serv/config.goSetDefault) that were never in the on-disk config. The saved file then carried a spurious top-leveldatabase:block, and the next reload (reload_on_config_change) or restart rejected it viaConfig.validateIsSourcesUsed("databases is legacy database-only config"), crash-looping the engine after any config apply. Even a minimalsource_patchesedit triggered it.Fix
When
IsSourcesUsed(), write a sanitized copy: drop thedatabase/databases/metadata/catalog/filesystems/openapikeys fromAllSettings()andWriteConfigthrough a fresh viper bound to the same file. A config written bygj_config.updatenow 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), andadd_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 saveddev.ymlno longer contains a top-leveldatabase:block.