Skip to content

Commit 717fe22

Browse files
nipunn1313Convex, Inc.
authored andcommitted
Classify invalid component path errors. (#43409)
This classifies them as user errors - to propagate error back to client GitOrigin-RevId: 79e7565ca24bc5e2eb85c55edd461d16e5e3f0a2
1 parent d0369d2 commit 717fe22

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/common/src/components/component_path.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88
str::FromStr,
99
};
1010

11+
use errors::ErrorMetadata;
1112
use itertools::Itertools;
1213
use sync_types::path::check_valid_path_component;
1314
use value::{
@@ -131,8 +132,11 @@ impl ComponentPath {
131132

132133
pub fn deserialize(path: Option<&str>) -> anyhow::Result<Self> {
133134
match path {
134-
Some(p) => p.parse(),
135135
None => Ok(ComponentPath::root()),
136+
Some(p) => p.parse().map_err(|e: anyhow::Error| {
137+
let msg = e.to_string();
138+
e.context(ErrorMetadata::bad_request("InvalidComponentPath", msg))
139+
}),
136140
}
137141
}
138142

0 commit comments

Comments
 (0)