fix: fix repo relative path. directly use Repo.save_path. - #575
Conversation
Greptile SummaryThe PR replaces codemap’s duplicated repository-path resolver with
Confidence Score: 4/5The URL normalization regression should be fixed before merging because whitespace-padded repository URLs now resolve as local paths and fail file reads. The new resolver forwards an untrimmed free-form URL into Files Needing Attention: api/services/codemap.py
|
| Filename | Overview |
|---|---|
| api/services/codemap.py | Repository path resolution is consolidated through Repo.save_path, but the change drops the prior whitespace normalization for repository URLs. |
Reviews (1): Last reviewed commit: "fix: fix repo relative path. directly us..." | Re-trigger Greptile
| def read_repo_file(repo_url: str, repo_type: str | None, file_path: str) -> str: | ||
| """Read a file from the cloned/local repository, guarding against traversal.""" | ||
| repo_dir = os.path.realpath(local_repo_dir(repo_url, repo_type)) | ||
| repo_dir = os.path.realpath(Repo(repo_url=repo_url, repo_type=repo_type).save_path) |
There was a problem hiding this comment.
Untrimmed URLs resolve as local paths
When repo_url contains leading or trailing whitespace, Repo receives the untrimmed value and fails to recognize it as a URL, causing the file lookup to use the wrong directory and raise FileNotFoundError.
| repo_dir = os.path.realpath(Repo(repo_url=repo_url, repo_type=repo_type).save_path) | |
| repo_dir = os.path.realpath( | |
| Repo(repo_url=repo_url.strip(), repo_type=repo_type).save_path | |
| ) |
Summary
Fix invalid code map snippet, mainly caused by typo. Now we redirect all attribute from
Repoclass instead for consistency.