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:
@@ -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:
|
def _record_profile_rename(new_dir: Path, old_canon: str) -> None:
|
||||||
"""Append ``old_canon`` to the renamed profile's ``previous_names`` history.
|
"""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:
|
try:
|
||||||
history = read_profile_meta(new_dir).get("previous_names") or []
|
history = read_profile_meta(new_dir).get("previous_names") or []
|
||||||
if old_canon not in history:
|
if old_canon not in history:
|
||||||
history = [*history, old_canon]
|
history = [*history, old_canon]
|
||||||
write_profile_meta(new_dir, previous_names=history)
|
write_profile_meta(new_dir, previous_names=history)
|
||||||
except Exception:
|
except Exception as exc: # unwritable / corrupt profile.yaml — history is advisory
|
||||||
pass
|
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:
|
def rename_profile(old_name: str, new_name: str) -> Path:
|
||||||
|
|||||||
Reference in New Issue
Block a user