From e53c3ff6bb3d447449257f2e4ff96350d565e1c6 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Wed, 13 May 2026 21:35:09 +0200 Subject: [PATCH] Fix schema default for array path exprs --- src/gmconfig.erl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gmconfig.erl b/src/gmconfig.erl index 338e432..c7b6fae 100644 --- a/src/gmconfig.erl +++ b/src/gmconfig.erl @@ -101,7 +101,7 @@ mock_config() -> mock_config(Cfg) -> ensure_schema_loaded(), - store(Cfg, Mode = silent). + store(Cfg, _Mode = silent). unmock_config() -> gmconfig_schema_utils:clear(), @@ -445,7 +445,20 @@ just_schema_keys(_) -> schema_default(Path) when is_list(Path) -> schema_default(Path, schema()). -schema_default(Path, Schema) -> +schema_default(Path0, Schema) -> + %% There is a way to navigate through an array of objects + %% essentially locating the desired object in the array, and then + %% continuing into one of its properties. This is specified in + %% a path exression as `{PropName, Value, ThenProp}`. + %% If the query expects us to fall back to the schema default, then + %% we must adapt the path accordingly. + %% + %% find_config([<<"system">>, <<"plugins">>, + %% {<<"name">>, PluginName, <<"config">>} | Key], + %% [user_config, schema_default]); + Path = lists:flatmap(fun({_, _,P}) -> [<<"items">>, P]; + (P) -> [P] + end, Path0), case schema(Path, Schema) of undefined -> undefined; {ok, Tree} ->