@@ -215,18 +215,16 @@ const MAX_MODULE_IDENTIFIER_LEN: usize = 256;
215215/// surface them properly. The inner layer's validation still runs as a
216216/// safety net, but would produce generic `ERR_INTERNAL` codes.
217217fn validate_napi_module_identifier ( value : & str , label : & str ) -> napi:: Result < ( ) > {
218- // Delegate core validation (empty, colons) to the shared implementation.
219- // Map through invalid_arg_error to preserve ERR_INVALID_ARG codes —
220- // Check length first to short-circuit expensive validation on
221- // accidentally large strings (DoS / multi-MB input guard).
218+ // First enforce a hard length limit to short‑circuit expensive validation on
219+ // accidentally large strings (DoS / multi‑MB input guard). Then delegate core
220+ // validation (e.g., emptiness, colons) to the shared implementation, mapping
221+ // its errors through invalid_arg_error so callers consistently receive
222+ // ERR_INVALID_ARG rather than generic ERR_INTERNAL codes.
222223 if value. len ( ) > MAX_MODULE_IDENTIFIER_LEN {
223224 return Err ( invalid_arg_error ( & format ! (
224225 "{label} must not exceed {MAX_MODULE_IDENTIFIER_LEN} bytes"
225226 ) ) ) ;
226227 }
227- // Delegate core validation (empty, colons) to the shared implementation.
228- // Map through invalid_arg_error to preserve ERR_INVALID_ARG codes —
229- // to_napi_error would produce ERR_INTERNAL for these validation errors.
230228 hyperlight_js:: validate_module_identifier ( value, label)
231229 . map_err ( |e| invalid_arg_error ( & e. to_string ( ) ) ) ?;
232230 if value. chars ( ) . any ( |c| c. is_control ( ) ) {
0 commit comments