fix(profiles,kanban): normalize profile IDs for assignees (salvage of #18518)#19700
Merged
Conversation
- Add normalize_profile_name() for lowercase canonical IDs and Default alias - Use canonical names in create/delete/rename/export/import/set_active paths - Canonicalize Kanban assignee on create/assign, list filter, and worker spawn - Tests for mixed-case assignees and profile resolution (fixes #18498)
…irst Follow-up to @changchun989's cherry-pick: reverts the validate-via- normalize change so validate_profile_name remains a strict regex check on the input AS-GIVEN. Callers that accept mixed-case user input (dashboard UI, CLI args, import flows) call normalize_profile_name() first, then validate the result. This keeps validate honest about what the on-disk directory name must look like — e.g. ' jules ' (trailing whitespace) is now rejected instead of silently trimmed and accepted. - validate_profile_name: strict lowercase/regex check again, 'UPPER' back in the invalid-names parametrize - 8 call sites in profiles.py (create_profile, delete_profile, set_active_profile, export_profile, import_profile, rename_profile, resolve_profile_env, plus the clone_from branch): swap the normalize-then-validate order - scripts/release.py: add changchun989@proton.me -> changchun989 to AUTHOR_MAP so CI doesn't block on the unmapped contributor email All kanban + profile tests pass (268 across test_profiles.py + test_kanban_db.py + test_kanban_core_functionality.py, plus 73 in test_kanban_tools.py + test_kanban_dashboard_plugin.py). Closes #18498.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #18498. Salvage of @changchun989's PR #18518 onto current main with a follow-up to keep
validate_profile_namestrict.Summary
Kanban tasks assigned to a mixed-case profile name (
Julesfrom the dashboard UI,hermes kanban assign ... Librarianfrom the CLI, etc.) now dispatch correctly. The dispatcher previously crashed withInvalid profile name 'Jules'. Must match [a-z0-9][a-z0-9_-]{0,63}because the assignee was stored verbatim and_default_spawnre-validated it before building thehermes -p <assignee>argv.Root cause
Profile directories are strictly lowercase (enforced by
_PROFILE_ID_REinhermes_cli/profiles.py), but ingress points (dashboard POST body, CLI args, import archive names) accepted arbitrary casing and stored it verbatim. The dispatcher's validate-then-spawn path exploded on the capital letter.Approach
normalize_profile_name()in profiles.py and threads it through every profile entry point —get_profile_dir,profile_exists,check_alias_collision,create_wrapper_script,remove_wrapper_script,create_profile,delete_profile,set_active_profile,export_profile,import_profile,rename_profile,resolve_profile_env— plus kanban'screate_task,list_tasks,assign_task, and_default_spawn. Adds_canonical_assigneehelper in kanban_db.py.validate_profile_namestrict — it checks input as-given against the regex, rather than silently normalizing. Callers that accept mixed-case user input normalize first, then validate. This keeps validate honest about what the on-disk directory name must look like; inputs like' jules '(trailing whitespace) get rejected instead of silently trimmed and accepted. 8 call sites in profiles.py updated to the new order.Validation
E2E tested with real imports against an isolated HERMES_HOME:
create_task(assignee="Jules")Julesjulesassign_task(tid, "Librarian")Librarianlibrarianlist_tasks(assignee="Jules")_default_spawnargvhermes -p Jules(crash)hermes -p julesvalidate_profile_name("Jules")validate_profile_name("UPPER")Targeted test runs:
tests/hermes_cli/test_profiles.py,tests/hermes_cli/test_kanban_db.py,tests/hermes_cli/test_kanban_core_functionality.py→ 268/268 passtests/tools/test_kanban_tools.py,tests/plugins/test_kanban_dashboard_plugin.py→ 73/73 passDuplicate PR closed
assign_task, leavingcreate_task(the more common ingress) unfixed. Will be closed with credit.AUTHOR_MAP
Added
changchun989@proton.me -> changchun989so release.py doesn't choke.