Open
Description
Sending an invalid search string from the front end may force the lambda to panic. E.g.
Sep 06 01:05:30.924 INFO stm_html_ui::handler: Raw path: /, Query: C++
Sep 06 01:05:30.924 INFO stm_html_ui::handler: Decoded path: /, query: C++, dev: None
Sep 06 01:05:30.925 INFO stm_html_ui::html: Terms: ["C++"]
Sep 06 01:05:30.925 ERROR stm_html_ui::elastic: Invalid field_value: c++
Sep 06 01:05:30.926 ERROR stm_html_ui::elastic: Invalid field_value: c++
Sep 06 01:05:30.926 ERROR stm_html_ui::elastic: Invalid field_value: c++
thread 'main' panicked at 'html() failed: ()', stm_html_ui/src/handler.rs:81:73
stack backtrace:
0: rust_begin_unwind
at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
1: core::panicking::panic_fmt
at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
2: core::result::unwrap_failed
at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/result.rs:1355:5
3: core::result::Result<T,E>::expect
at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/result.rs:997:23
4: stm_html_ui::handler::my_handler::{{closure}}
at ./src/handler.rs:81:21
The problem is in handler.rs unwrapping via expect
:
let html_data = html::html(&config, url_path, url_query, dev).await.expect("html() failed");
There should be match
and a meaningful error message returned to the user.