Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing "required" fields to node_config table #14813

Open
friofry opened this issue May 16, 2024 · 0 comments · May be fixed by status-im/status-go#5307
Open

add missing "required" fields to node_config table #14813

friofry opened this issue May 16, 2024 · 0 comments · May be fixed by status-im/status-go#5307
Assignees
Labels
backend-team bug Something isn't working E:Msg Bugfixes 2.30 Messaging bugfixes for 2.30
Milestone

Comments

@friofry
Copy link
Contributor

friofry commented May 16, 2024

Bug Report

Description

KeycardPairingDataFile string validate:"required" is marked as required in config.go

But it's not inserted/loaded in node_config.go:

insertNodeConfig:
    INSERT OR REPLACE INTO node_config (
        network_id, data_dir, keystore_dir, node_key, no_discovery, rendezvous,
        listen_addr, advertise_addr, name, version, api_modules, tls_enabled,
        max_peers, max_pending_peers, enable_status_service, enable_ntp_sync,
        bridge_enabled, wallet_enabled, local_notifications_enabled,
        browser_enabled, permissions_enabled, mailservers_enabled,
        swarm_enabled, mailserver_registry_address, web3provider_enabled, synthetic_id
    ) 

Having a valid config would allow us to avoid infinite crashes like #14643 when an invalid config was written to the database. Probably we should callnodeConfig.Validate in parseSaveAndSyncSetting in database.go

Steps to reproduce

Try adding the following test to node_config_test.go:

func TestConfigValidate(t *testing.T) {
	// GIVEN
	db, stop := setupTestDB(t)
	defer stop()

	tmpdir := t.TempDir()
	nodeConfig, err := params.NewNodeConfig(tmpdir, 1777)

	require.NoError(t, err)
	err = nodeConfig.Validate()
	require.NoError(t, err)
	require.NoError(t, nodecfg.SaveNodeConfig(db, nodeConfig))

	// WHEN
	dbNodeConfig, err := nodecfg.GetNodeConfigFromDB(db)
	require.NoError(t, err)

	// THEN
	err = dbNodeConfig.Validate()
	require.NoError(t, err)
}

it fails with

Error:      	Received unexpected error:
	Key: 'NodeConfig.KeycardPairingDataFile' Error:Field validation for 'KeycardPairingDataFile' failed on the 'required' tag

Expected behavior

Node Config in the database should be valid

Actual behavior

Required fields are missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend-team bug Something isn't working E:Msg Bugfixes 2.30 Messaging bugfixes for 2.30
Projects
Status: Code review
Development

Successfully merging a pull request may close this issue.

2 participants