fix(search): soft-fail on per-row excluded type and malformed regex name
R-CMD-check / check (push) Successful in 1m37s
R-CMD-check / check (pull_request) Successful in 1m37s

Cross-task review found two edge cases that violated the basket-mode
soft-fail contract:

- Per-row excluded type (e.g. type = c(NA, "special_district")) hit
  .coerce_type()'s abort inside the per-row resolver, killing the
  whole basket call. Now treated as no_match in the sidecar.
- Malformed regex in the substring fallback (e.g. name = "San(Diego")
  propagated DuckDB engine errors. .escape_regex() now backslash-
  escapes meta characters before the regexp_matches call. Utility-
  mode regex behavior is unchanged.

Plus a new public-surface test for the all-no-match case.
This commit is contained in:
2026-04-28 14:16:37 -04:00
parent 24e67791a0
commit efc0bd16b1
3 changed files with 86 additions and 2 deletions
+4 -1
View File
@@ -39,9 +39,12 @@
}
# Convert a type input (integer-like or label) into the canonical label
# string used in the sidecar query_type column.
# string used in the sidecar query_type column. Excluded types (4/5 /
# special_district / school_district) are returned as-is so the sidecar
# records what the user passed without calling .coerce_type() (which aborts).
#' @noRd
.type_to_label <- function(type) {
if (.is_excluded_type(type)) return(as.character(type))
int_type <- .coerce_type(type)
unname(c("0" = "state", "1" = "county", "2" = "city", "3" = "township")[[as.character(int_type)]])
}