Skip to content

Commit f21e516

Browse files
committed
fix(core): warn when focus depth is clamped to MAX_FOCUS_DEPTH
Previously, FocusSpec silently clamped depth values exceeding MAX_FOCUS_DEPTH (10). Now emit a tracing::warn with the requested and maximum values so users are aware their input was adjusted.
1 parent ffacf6e commit f21e516

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/relune-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ petgraph.workspace = true
1010
serde.workspace = true
1111
serde_json = { workspace = true }
1212
thiserror.workspace = true
13+
tracing.workspace = true
1314

1415
[lints]
1516
workspace = true

crates/relune-core/src/config.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,27 @@ where
3333
D: serde::Deserializer<'de>,
3434
{
3535
let value = u32::deserialize(deserializer)?;
36+
if value > MAX_FOCUS_DEPTH {
37+
tracing::warn!(
38+
requested = value,
39+
max = MAX_FOCUS_DEPTH,
40+
"focus depth exceeds maximum, clamping to {MAX_FOCUS_DEPTH}",
41+
);
42+
}
3643
Ok(value.min(MAX_FOCUS_DEPTH))
3744
}
3845

3946
impl FocusSpec {
4047
/// Creates a new `FocusSpec`, clamping `depth` to [`MAX_FOCUS_DEPTH`].
4148
#[must_use]
4249
pub fn new(table: impl Into<String>, depth: u32) -> Self {
50+
if depth > MAX_FOCUS_DEPTH {
51+
tracing::warn!(
52+
requested = depth,
53+
max = MAX_FOCUS_DEPTH,
54+
"focus depth exceeds maximum, clamping to {MAX_FOCUS_DEPTH}",
55+
);
56+
}
4357
Self {
4458
table: table.into(),
4559
depth: depth.min(MAX_FOCUS_DEPTH),

0 commit comments

Comments
 (0)