Skip to content

fix(config): a missing seed YAML must not start setup over live Settings #1153

Description

@frahlg

A missing leftover config.yaml starts the setup wizard even when state.db already holds Settings. Finishing the wizard can commit that new YAML over live configuration.

Found on master 6eadec3f (schema 2: settings live in SQLite; YAML is a locator and rollback seed).

What happens

cfg, err := config.Load(*configPath)
if err != nil {
    if isConfigMissing(*configPath) {
        runBootstrap(*configPath, *webDir, resolveDriverDir())
        return
    }
}

isConfigMissing is only Lstat of the seed path. It does not look for state.db or settings/config_v1.

The wizard writes a new YAML. InitializeStorage then sees an existing settings row whose YAMLSourceHash does not match the new file, sets legacySave, and saveStored commits the wizard document over the live Settings (go/internal/config/storage.go).

The same legacySave path fires if the leftover seed is edited or config_database is removed: YAML becomes authority again.

TestMissingDatabaseDoesNotStartSetup only covers the inverse (locator present, DB gone).

What a fix needs

  • If state.db already has settings/config_v1, do not enter the wizard because the seed file is missing. Recreate the locator YAML from SQLite instead.
  • Refuse legacySave when the new YAML is a wizard/default document rather than an old-Core rollback save.
  • Tests: delete config.yaml, keep state.db with Settings, start Core — Settings unchanged, locator rewritten, wizard not shown.
  • Same for an edited leftover seed.

This is a data-loss path on every schema-2 box that still has a seed file beside the DB (the documented layout).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions