Skip to content

Commit 12e4cff

Browse files
committed
fix(cluster,native): minor correctness fixes in applier and plan builders
- `metadata_group/applier.rs`: remove stale doc comment that described `apply_topology_change` as backward-compatible with old test wiring; the field is simply optional. - `plan_builder/graph.rs`: correct `clamped_depth` parameter from `Option<u64>` to `Option<u32>` to match the wire field type. - `plan_builder/vector.rs`: add explicit `u32` bounds check on `vector_id` with a structured `BadRequest` error rather than silently truncating the surrogate.
1 parent bf16780 commit 12e4cff

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

nodedb-cluster/src/metadata_group/applier.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ impl CacheApplier {
114114
}
115115

116116
/// Mutate the live topology handle (if attached) in response to
117-
/// a committed `TopologyChange`. Silent no-op when no handle is
118-
/// set — backward-compatible with older test wiring.
117+
/// a committed `TopologyChange`. Optional; no-op when not configured.
119118
fn apply_topology_change(&self, change: &TopologyChange) {
120119
let Some(live) = &self.live_topology else {
121120
return;

nodedb/src/control/server/native/dispatch/plan_builder/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::parse_direction;
1414
/// rejecting out-of-range values rather than forwarding them to the
1515
/// engine. Mirrors the pgwire ingress so no entry point can saturate
1616
/// traversal with an unbounded fan-out.
17-
fn clamped_depth(value: Option<u64>, default: usize, field: &str) -> crate::Result<usize> {
17+
fn clamped_depth(value: Option<u32>, default: usize, field: &str) -> crate::Result<usize> {
1818
let v = value.map(|v| v as usize).unwrap_or(default);
1919
if v > MAX_GRAPH_TRAVERSAL_DEPTH {
2020
return Err(crate::Error::BadRequest {

nodedb/src/control/server/native/dispatch/plan_builder/vector.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,14 @@ pub(crate) fn build_multi_search(
133133
}
134134

135135
pub(crate) fn build_delete(fields: &TextFields, collection: &str) -> crate::Result<PhysicalPlan> {
136-
let vector_id = fields.vector_id.ok_or_else(|| crate::Error::BadRequest {
136+
let vector_id_wire = fields.vector_id.ok_or_else(|| crate::Error::BadRequest {
137137
detail: "missing 'vector_id'".to_string(),
138138
})?;
139+
let vector_id: u32 = vector_id_wire
140+
.try_into()
141+
.map_err(|_| crate::Error::BadRequest {
142+
detail: "vector_id exceeds 32-bit surrogate space".to_string(),
143+
})?;
139144

140145
Ok(PhysicalPlan::Vector(VectorOp::Delete {
141146
collection: collection.to_string(),

0 commit comments

Comments
 (0)