From c68370609d086534cf4237026068b6b0bed8cb95 Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Sun, 12 Apr 2026 23:07:46 -0300 Subject: [PATCH] fix: address Copilot review comments on PR #739 - query_sanitizer: require matching quote pair in _strip_wrapping_quotes - query_sanitizer: re-check MIN_QUERY_LENGTH after trim in tail_sentence path - migrate: neutral confirmation message accurate for both migrate and repair - cli: os.path.normpath instead of rstrip to handle '/' root edge case --- mempalace/cli.py | 2 +- mempalace/migrate.py | 2 +- mempalace/query_sanitizer.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mempalace/cli.py b/mempalace/cli.py index 806abcc..8bf3f20 100644 --- a/mempalace/cli.py +++ b/mempalace/cli.py @@ -225,7 +225,7 @@ def cmd_repair(args): print(f" Extracted {len(all_ids)} drawers") # Backup and rebuild - palace_path = palace_path.rstrip(os.sep) + palace_path = os.path.normpath(palace_path) backup_path = palace_path + ".backup" if os.path.exists(backup_path): if not contains_palace_database(backup_path): diff --git a/mempalace/migrate.py b/mempalace/migrate.py index 40a9701..6ec4a59 100644 --- a/mempalace/migrate.py +++ b/mempalace/migrate.py @@ -117,7 +117,7 @@ def confirm_destructive_action( return True print(f"\n {operation_name} will replace data in: {palace_path}") - print(" A backup will be created first, but the original directory will be deleted.") + print(" A backup will be created first, then the palace will be rebuilt.") try: answer = input(" Continue? [y/N]: ").strip().lower() except EOFError: diff --git a/mempalace/query_sanitizer.py b/mempalace/query_sanitizer.py index 91d0ca2..774baea 100644 --- a/mempalace/query_sanitizer.py +++ b/mempalace/query_sanitizer.py @@ -71,7 +71,7 @@ def sanitize_query(raw_query: str) -> dict: def _strip_wrapping_quotes(candidate: str) -> str: candidate = candidate.strip() while ( - len(candidate) >= 2 and candidate[:1] in QUOTE_CHARS and candidate[-1:] in QUOTE_CHARS + len(candidate) >= 2 and candidate[:1] in QUOTE_CHARS and candidate[:1] == candidate[-1:] ): candidate = candidate[1:-1].strip() if not candidate: @@ -158,6 +158,8 @@ def sanitize_query(raw_query: str) -> dict: seg = seg.strip() if len(seg) >= MIN_QUERY_LENGTH: candidate = _trim_candidate(seg) + if len(candidate) < MIN_QUERY_LENGTH: + continue logger.warning( "Query sanitized: %d → %d chars (method=tail_sentence)", original_length,