Skip to content

Commit c0eae13

Browse files
committed
fix(tools): preserve rss search path errors
Keep leaf-symlink search-root cap::fs_list failures as path_denied and normalize only the message, matching native SearchFiles dispatch.
1 parent f7d157c commit c0eae13

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎rss/tools/search_files.rss‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ fn walk_search(state: map, path: string, depth: int) -> map {
595595
let mut mapped_code: string = code;
596596
let mut mapped_message: string = types::map_string(error, "message", "");
597597
if mapped_message == "symlinks are not followed" {
598-
mapped_code = "wrong_type";
599598
mapped_message = "operating-system operation failed";
600599
} else {
601600
if code == "wrong_type" {

‎tests/rss_file_tool_tests.rs‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,37 @@ fn search_caps_invalid_paths_and_symlinks_match_native() {
892892
assert_search_eq(&fixture, json!({"pattern": "alpha", "path": "../outside"}));
893893
assert_search_eq(&fixture, json!({"pattern": "alpha", "path": "/tmp"}));
894894
assert_search_eq(&fixture, json!({"pattern": "alpha", "path": "missing"}));
895-
assert_search_eq(&fixture, json!({"pattern": "alpha", "path": "leaf-link"}));
895+
896+
let leaf_link_arguments = json!({"pattern": "alpha", "path": "leaf-link"});
897+
let native_leaf_link = native_execute(
898+
&fixture.tools(),
899+
NativeToolExecutor::SearchFiles,
900+
&leaf_link_arguments,
901+
);
902+
let rss_leaf_link = run_rss_search(&fixture, &fixture.config(), leaf_link_arguments);
903+
let expected_leaf_link = json!({
904+
"ok": false,
905+
"content": "",
906+
"data": {},
907+
"error": {
908+
"code": "path_denied",
909+
"message": "operating-system operation failed"
910+
},
911+
"truncated": false,
912+
"artifacts": []
913+
});
914+
assert_eq!(
915+
canonical_envelope(&rss_leaf_link.result),
916+
expected_leaf_link
917+
);
918+
assert_eq!(
919+
native_leaf_link
920+
.error
921+
.as_ref()
922+
.map(|error| error.message.as_str()),
923+
Some("operating-system operation failed")
924+
);
925+
assert!(!native_leaf_link.ok);
896926

897927
let mut config = fixture.config();
898928
config.max_search_matches = 1;

0 commit comments

Comments
 (0)