Skip to content

Commit 52d8061

Browse files
committed
fix(gateway): address runtime config review feedback
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
1 parent b87084d commit 52d8061

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

crates/openshell-server/src/grpc/policy.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,15 @@ async fn handle_update_config_inner(
14921492
if req.global {
14931493
let _settings_guard = state.settings_mutex.lock().await;
14941494

1495+
// Check this before dispatching the global mutation. Keep the check
1496+
// under settings_mutex so a runtime-file reload cannot change key
1497+
// ownership between this check and the stored-settings write.
1498+
if has_setting && state.runtime_settings.is_managed_key(key) {
1499+
return Err(Status::failed_precondition(format!(
1500+
"setting '{key}' is managed by the gateway runtime config file; update that file instead"
1501+
)));
1502+
}
1503+
14951504
if has_merge_ops {
14961505
return Err(Status::invalid_argument(
14971506
"merge_operations are not supported for global policy updates",
@@ -1607,12 +1616,6 @@ async fn handle_update_config_inner(
16071616
if key != POLICY_SETTING_KEY {
16081617
validate_registered_setting_key(key)?;
16091618
}
1610-
if state.runtime_settings.is_managed_key(key) {
1611-
return Err(Status::failed_precondition(format!(
1612-
"setting '{key}' is managed by the gateway runtime config file; update that file instead"
1613-
)));
1614-
}
1615-
16161619
let mut global_settings = load_global_settings(state.store.as_ref()).await?;
16171620
let changed = if req.delete_setting {
16181621
let removed = global_settings.settings.remove(key).is_some();
@@ -9283,7 +9286,6 @@ mod tests {
92839286
);
92849287
}
92859288

9286-
#[cfg(feature = "dev-settings")]
92879289
#[test]
92889290
fn merge_effective_settings_global_overrides_sandbox_key() {
92899291
let global = StoredSettings {

docs/reference/gateway-config.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ Startup configuration is distinct from runtime settings such as `providers_v2_en
1818
Gateway CLI flag > gateway OPENSHELL_* env var > TOML file > built-in default
1919
```
2020

21+
This precedence applies only to startup configuration, including the
22+
`runtime_config_path` that selects the second file. Runtime setting keys are not
23+
exposed as gateway process flags or `OPENSHELL_*` environment variables. For a
24+
key present in the runtime settings file, that file is authoritative and the
25+
gateway rejects global API or CLI writes. A key omitted from the runtime file
26+
uses its stored global value and remains mutable through `openshell settings`.
27+
2128
`database_url` is env-only. The loader rejects it when it appears in the file. When `OPENSHELL_DB_URL` is unset, the gateway stores its SQLite database under `$XDG_STATE_HOME/openshell/gateway/openshell.db`.
2229

2330
## Package-Managed Locations

0 commit comments

Comments
 (0)