fix(profiles): log the tolerated failure when a rename cannot record its previous name

`_record_profile_rename` swallowed every exception silently. The history is
advisory (group-chat member re-link), so the rename must still succeed, but
an unwritable or corrupt profile.yaml now leaves a debug line naming the
profile and the error instead of vanishing.

The docstring also records why no default / no-op guard is needed here:
`rename_profile` returns before this helper for the default profile
(display-name only) and refuses `old == new` because the target directory
already exists.
This commit is contained in:
teknium1
2026-09-20 00:22:32 -07:00
committed by Teknium
parent bc15892315
commit 680dd93b26

View File

@@ -1987,14 +1987,17 @@ def _migrate_honcho_profile_host(old_name: str, new_name: str, new_dir: Path) ->
def _record_profile_rename(new_dir: Path, old_canon: str) -> None:
"""Append ``old_canon`` to the renamed profile's ``previous_names`` history.
Best-effort: never raises, so a metadata write failure cannot fail the rename."""
Best-effort: never raises, so a metadata write failure cannot fail the rename.
Only reached for a real slug change — ``rename_profile`` returns early for the
default profile (display-name only) and refuses ``old == new`` (target exists)."""
try:
history = read_profile_meta(new_dir).get("previous_names") or []
if old_canon not in history:
history = [*history, old_canon]
write_profile_meta(new_dir, previous_names=history)
except Exception:
pass
except Exception as exc: # unwritable / corrupt profile.yaml — history is advisory
logger.debug("profile rename: could not record previous name %r in %s: %s", old_canon, new_dir, exc)
def rename_profile(old_name: str, new_name: str) -> Path: