qml: Stabilize onboarding settings and data directories

bitcoin-core/gui-qml: PR #883

1 major finding · 5 minor findings · 1 suggestion

Findings

Link

[major] · Startup-error test driver leaves onboarding alerts undetected and undismissed

Source inspection shows that the held-directory and two blocksdir cases have no alert-dismissal path, so they reach the 30-second subprocess timeout and fail the new CI test.

Location: test/test_startup_errors.cpp:31 (head).

Details and suggested fix

These three cases pass -qml_onboarded=0, so qmlEngineCreated() first runs on the onboarding engine. Its one-shot callback finds no message context property and returns. The onboarding timer then emits finished and stops. When preparation fails, startup_error_window routes the error to StartupErrorInWindow(), which opens preInitStartupErrorPopup and waits for acknowledgement without creating another engine. Nothing observes or dismisses that popup, STARTUP_ERROR: is never printed, and observed_error remains false. Even dismissing the alert alone would therefore leave the test failing. Add an observer for the onboarding popup and its message that verifies visibility, records the error, prints the marker, and acknowledges the popup. Keep the standalone-engine handling for errors raised before onboarding.


Link

[minor] · -noconf blocks onboarding with a new data folder

With -noconf, choosing a folder that does not yet exist, including a missing saved folder, produces a configuration preview error and prevents onboarding from finishing.

Location: qml/onboarding_settings.cpp:285 (head).

Details and suggested fix

IsArgSet("-conf") is true for -noconf, but pinned Core's GetPathArg() returns an empty path for the negated value. ReadConfigForNewDataDir() joins that empty path to the selected directory and tries to read the directory path as a configuration file. Core instead treats the empty path as configuration reading being disabled. The resulting preview error keeps canFinish() false; the base new-folder branch did not attempt this read. Resolve the option with GetPathArg("-conf", BITCOIN_CONF_FILENAME) and handle an empty result before joining paths. This also distinguishes -noconf from -conf=, for which Core uses the default filename. Add a negated-config case to the new-folder preview tests.


Link

[minor] · Legacy cleanup rollback can reverse default-valued onboarding choices

With mixed writable and read-only legacy stores, cleanup rollback can restore an obsolete value and reverse a default-valued onboarding choice on restart; occurrence in production is unconfirmed.

Location: qml/legacy_settings_migration.cpp:253 (head).

Details and suggested fix

For example, let the writable BitcoinCore-App-regtest store contain server=true and a separate dirty Bitcoin-Qt store be read-only. Choosing server off during onboarding removes the server override because false is the default. After saving settings.json, cleanup removes the writable store's obsolete key, fails on the read-only store, and calls RestoreStores() for both. FinalizeStartupSettings() only logs the failure and preserves the current process's committed values. On the next startup, WriteMigratedSetting() sees no persistent server value and imports the restored true value again. Base synced each store independently, so the successful removal stayed removed. Make this best-effort cleanup commit stores independently rather than restoring successful removals when another store fails, and add a restart test that reruns migration.


Link

[minor] · -resetguisettings resolves and locks the blocks directory before clearing it

For manually or externally added blocksdir values, -resetguisettings can fail on the discarded path or keep it cached for the session; no current GUI/Core caller writes this setting.

Location: qml/bitcoin.cpp:739 (head).

Details and suggested fix

InitConfig() loads settings.json into rw_settings, whose values take precedence over configuration-file values. The new GetBlocksDirPath() check and AppInitLockDirectories() run before FinalizeStartupSettings() clears those settings for reset. A missing blocksdir therefore aborts startup before reset can recover the profile. An existing one is cached and locked, so this session uses the removed location while the next launch uses the default. Base reset cleared the file before normal initialization. Stage the reset's cleared effective settings before resolving and locking directories, retain the originals for backup and rollback, and invalidate the path cache before taking the locks. Production occurrence of this externally edited setting is unconfirmed.


Link

[minor] · New-folder preview ignores existing data in explicit external directories

A missing custom folder is classified as fresh despite populated explicit -blocksdir or -walletdir paths, changing storage requirements and automatic prune recommendations; production frequency is unknown.

Location: qml/onboarding_settings.cpp:1191 (head).

Details and suggested fix

The new-folder branch sets existing_profile only from has_config_file instead of calling BuildProfileSummary(). It therefore misses the existing block-data and absolute wallet-directory probes that base performed. Without a config file, the model can now automatically stage pruning when its fresh-chain storage threshold is not met, provided pruning remains editable and default-sourced. It also displays fresh-profile space requirements rather than the existing-profile requirements. The same external data is detected if the selected folder already exists. An existing absolute -settings file is similarly read but omitted from the profile summary. Keep excluding the unused default profile, but still probe explicit external block, wallet, and settings paths when the selected folder does not exist.


Link

[minor] · choosedatadir=1 in bitcoin.conf no longer opens onboarding

For an onboarded usable profile without a command-line -datadir, choosedatadir=1 in bitcoin.conf is ignored because the chooser request is captured before configuration parsing.

Location: qml/onboarding_settings.cpp:1062 (head).

Details and suggested fix

force_data_dir_chooser is computed before ReadResolvedProfile(). The final force_show_onboarding expression re-evaluates -resetguisettings against the resolved profile but never re-evaluates -choosedatadir. Base called ShouldShowDataDirChooser() after reading config, so the same request opened the wizard. Retain the early snapshot needed for command-line chooser requests, but also honor the resolved -choosedatadir value when no explicit command-line -datadir is present. There is no dedicated test or documented contract for the config-sourced case, so please confirm whether this behavior change is intentional and cover the selected contract.


Optional improvements

Link

[suggestion] · Profile-change guard omits resolved_network_dir

A custom signet challenge changed during onboarding escapes the profile-change guard when -settings is absolute, allowing choices to apply to a different network directory than the one previewed.

Location: qml/onboarding_settings.cpp:829 (head).

Details and suggested fix

Preview() records Core's resolved_network_dir, and PrepareSettingsDirectory() uses it to create the previewed network's wallet directory before InitConfig() rereads configuration. If signetchallenge changes in bitcoin.conf after that preview, the base data directory and chain string remain unchanged. An absolute settings path also remains unchanged, so ValidatePendingApply() accepts the different network directory. Compare CreateBaseChainParams(args, args.GetChainType())->DataDir() with pending.resolved_network_dir alongside the existing checks. Add a drift test that changes the challenge while keeping the settings path absolute.


Coverage details