{"record":{"id":"4c391236c8fd75a1","repo":"tirth8205/code-review-graph","slug":"alias-effective-alias-is-already-in-use-by-ex","errorCode":null,"errorMessage":"Alias '{effective_alias}' is already in use by {existing.path}","messagePattern":"Alias '(.+?)' is already in use by (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"code_review_graph/daemon.py","lineNumber":346,"sourceCode":"    has_repo_marker = (\n        (resolved / \".git\").exists()\n        or (resolved / \".svn\").exists()\n        or (resolved / \".code-review-graph\").exists()\n    )\n    if not has_repo_marker:\n        raise ValueError(f\"No .git, .svn, or .code-review-graph directory in {resolved}\")\n\n    effective_alias = alias or resolved.name\n\n    config = load_config(config_path)\n\n    # Check for duplicate path or alias\n    for existing in config.repos:\n        if existing.path == str(resolved):\n            logger.warning(\"Repo %s is already configured — skipping\", resolved)\n            return config\n        if existing.alias == effective_alias:\n            raise ValueError(f\"Alias '{effective_alias}' is already in use by {existing.path}\")\n\n    config.repos.append(WatchRepo(path=str(resolved), alias=effective_alias))\n    save_config(config, config_path)\n    return config\n\n\ndef remove_repo_from_config(\n    path_or_alias: str,\n    config_path: Path | None = None,\n) -> DaemonConfig:\n    \"\"\"Remove a repository from the daemon config by path or alias.\n\n    Args:\n        path_or_alias: Either the absolute/relative repo path or its alias.\n        config_path:   Explicit config file path.  Falls back to :func:`default_config_path`.\n\n    Returns:\n        The updated :class:`DaemonConfig`.","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/daemon.py#L328-L364","documentation":"When adding a repo to the daemon config, aliases must be unique. If the computed or supplied alias already maps to a different configured repo, add_repo_to_config raises ValueError instead of silently shadowing it. Note: a duplicate PATH is not an error — it logs a warning and returns the existing config unchanged.","triggerScenarios":"Calling daemon add with an --alias that matches another repo's alias, or adding two repos whose directory basenames are identical (the alias defaults to resolved.name), e.g. two checkouts both named 'api'.","commonSituations":"Multiple worktrees/clones of the same project in different locations, monorepos with same-named subdirectories, or reusing a friendly alias like 'main' across machines/copies.","solutions":["Pass a distinct --alias: `code-review-graph daemon add ~/work/api --alias work-api`","Or remove/rename the existing repo entry that owns the alias (edit the daemon config TOML or use the remove command), then retry","When scripting, derive aliases from the full path (not basename) to guarantee uniqueness"],"exampleFix":"# before\n$ code-review-graph daemon add ~/work/api\nValueError: Alias 'api' is already in use by /home/me/src/api\n\n# after\n$ code-review-graph daemon add ~/work/api --alias work-api","handlingStrategy":"validation","validationCode":"from code_review_graph.daemon import load_config, default_config_path\n\ncfg = load_config(default_config_path())\nresolved = str(Path(repo_path).expanduser().resolve())\nalias = my_alias or Path(resolved).name\ntaken = {r.alias for r in cfg.repos}\nassert alias not in taken, f\"alias {alias!r} already used; try {alias}-2\"","typeGuard":"def is_alias_free(cfg, alias: str) -> bool:\n    return all(r.alias != alias for r in cfg.repos)","tryCatchPattern":"try:\n    add_repo_to_config(repo_path, alias)\nexcept ValueError as e:\n    if \"already in use\" in str(e):\n        add_repo_to_config(repo_path, f\"{alias or Path(repo_path).name}-{Path(repo_path).parent.name}\")\n    else:\n        raise","preventionTips":["Always pass explicit --alias values derived from the full path when scripting","Check the daemon config TOML for existing aliases before adding","Remember duplicate paths are silently skipped; only aliases raise — inspect config after adds"],"tags":["daemon","config","alias-conflict","valueerror"],"backgroundTag":"duplicate-config-identifier","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}