app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit f9f14635b3ab4ddad25fbc83b7b301583c8c9268
parent 0e6ca7f3b9f79e3a15377eaf68770c56242b7fad
Author: triesap <triesap@radroots.dev>
Date:   Mon, 19 Jan 2026 17:26:57 +0000

app: validate key maps during init

- add config error variant to AppInitError
- validate datastore key maps before idb bootstrap
- keep init error messages aligned with new variant
- add test coverage for config error mapping

Diffstat:
Mapp/src/init.rs | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/app/src/init.rs b/app/src/init.rs @@ -14,7 +14,7 @@ use radroots_app_core::idb::{ }; use radroots_app_core::keystore::{RadrootsClientKeystoreError, RadrootsClientWebKeystoreNostr}; -use crate::AppConfig; +use crate::{app_key_maps_validate, AppConfig, AppConfigError}; #[cfg(target_arch = "wasm32")] use leptos::prelude::window; @@ -82,6 +82,7 @@ pub enum AppInitError { Idb(RadrootsClientIdbStoreError), Datastore(RadrootsClientDatastoreError), Keystore(RadrootsClientKeystoreError), + Config(AppConfigError), } pub type AppInitErrorMessage = &'static str; @@ -92,6 +93,7 @@ impl AppInitError { AppInitError::Idb(_) => "error.app.init.idb", AppInitError::Datastore(_) => "error.app.init.datastore", AppInitError::Keystore(_) => "error.app.init.keystore", + AppInitError::Config(_) => "error.app.init.config", } } } @@ -151,6 +153,7 @@ pub fn app_init_reset() { } pub async fn app_init_backends(config: AppConfig) -> AppInitResult<AppBackends> { + app_key_maps_validate(&config.datastore.key_maps).map_err(AppInitError::Config)?; idb_store_bootstrap(RADROOTS_IDB_DATABASE, None) .await .map_err(AppInitError::Idb)?; @@ -180,6 +183,7 @@ mod tests { use radroots_app_core::datastore::RadrootsClientDatastoreError; use radroots_app_core::idb::RadrootsClientIdbStoreError; use radroots_app_core::keystore::RadrootsClientKeystoreError; + use crate::AppConfigError; #[test] fn app_init_error_messages_match_spec() { @@ -196,6 +200,10 @@ mod tests { AppInitError::Keystore(RadrootsClientKeystoreError::IdbUndefined), "error.app.init.keystore", ), + ( + AppInitError::Config(AppConfigError::MissingKeyMap("nostr_key")), + "error.app.init.config", + ), ]; for (err, expected) in cases { assert_eq!(err.message(), *expected);