Skip to content

fix(adhoc-sweep-fixes): CU-86akn96pk 3 review findings across 3 files - #94

Draft
flamingo[bot] wants to merge 3 commits into
mainfrom
ai-fix/adhoc-sweep-fixes-ce0fb128-90e36f49
Draft

flamingo[bot] wants to merge 3 commits into
mainfrom
ai-fix/adhoc-sweep-fixes-ce0fb128-90e36f49

Conversation

@flamingo

@flamingo flamingo Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Closes 3 review findings across 3 files.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟢 90 high clone_repository leaves target_dir cleanup inconsistent between shallow and full clone failure paths codewiki/src/fe/github_processor.py:66
2 🟢 90 high repo_validator.py silently swallows all exceptions when reading git metadata, hiding real errors codewiki/cli/utils/repo_validator.py:144
3 🟡 75 medium serve_generated_docs path-traversal guard only checks parents/equality, not symlink resolution, and differs from visualise_docs.py's is_relative_to check codewiki/src/fe/routes.py:245

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 90e36f49-f8c5-4b9a-a9b0-2d911418acb4

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

ClickUp task: CU-86akn96pk CodeWiki review findings sweep (9 PRs)

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 What this fix changed, finding by finding

3 finding(s) fixed in this draft — 3 explained inline on the diff.

Comment on lines 71 to 78

if result.returncode != 0:
logger.error(f"Error cloning repository: {result.stderr}")
if os.path.isdir(target_dir):
shutil.rmtree(target_dir, ignore_errors=True)
return False

# Checkout specific commit

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 clone_repository leaves target_dir cleanup inconsistent between shallow and full clone failure paths

In GitHubRepoProcessor.clone_repository, added shutil.rmtree(target_dir, ignore_errors=True) cleanup (guarded by os.path.isdir(target_dir)) to both the commit_id branch's initial git clone failure path and the shallow-clone branch's git clone failure path, matching the existing cleanup behavior already present in the checkout-failure path and the outer except Exception handler. This ensures partial/corrupted clone directories are removed consistently on any clone failure.

🤖 Prompt for AI agents
In codewiki/src/fe/github_processor.py around line 66, review and complete this code-review fix: clone_repository leaves target_dir cleanup inconsistent between shallow and full clone failure paths.
What the draft fix changed: In GitHubRepoProcessor.clone_repository, added `shutil.rmtree(target_dir, ignore_errors=True)` cleanup (guarded by `os.path.isdir(target_dir)`) to both the commit_id branch's initial `git clone` failure path and the shallow-clone branch's `git clone` failure path, matching the existing cleanup behavior already present in the checkout-failure path and the outer `except Exception` handler. This ensures partial/corrupted clone directories are removed consistently on any clone failure.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment on lines 150 to 156
repo = git.Repo(repo_path)
return repo.head.commit.hexsha
except Exception:
logger.debug("Failed to read git commit hash for %s", repo_path, exc_info=True)
return ""


Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 repo_validator.py silently swallows all exceptions when reading git metadata, hiding real errors

In get_git_commit_hash and get_git_branch, added logger.debug(..., exc_info=True) calls in the except Exception: blocks before returning "", and added a module-level logger = logging.getLogger(__name__) plus import logging. This logs the swallowed exception details at debug level so real errors (corrupted .git, missing dependency, permissions) are traceable without changing observable behavior (still returns empty string).

🤖 Prompt for AI agents
In codewiki/cli/utils/repo_validator.py around line 144, review and complete this code-review fix: repo_validator.py silently swallows all exceptions when reading git metadata, hiding real errors.
What the draft fix changed: In `get_git_commit_hash` and `get_git_branch`, added `logger.debug(..., exc_info=True)` calls in the `except Exception:` blocks before returning `""`, and added a module-level `logger = logging.getLogger(__name__)` plus `import logging`. This logs the swallowed exception details at debug level so real errors (corrupted .git, missing dependency, permissions) are traceable without changing observable behavior (still returns empty string).
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment thread codewiki/src/fe/routes.py
pass

# Serve the requested file
docs_path_resolved = docs_path.resolve()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 serve_generated_docs path-traversal guard only checks parents/equality, not symlink resolution, and differs from visualise_docs.py's is_relative_to check

In serve_generated_docs (routes.py), replaced the docs_path_resolved != file_path and docs_path_resolved not in file_path.parents containment check with file_path.is_relative_to(docs_path_resolved), matching the approach used in visualise_docs.py's serve_doc. Added a .md extension allowlist check on filename before resolving paths, and wrapped the .resolve() calls plus containment check in a try/except that raises HTTPException(400, "Invalid file path") on any exception, mirroring the defensive try/except pattern in visualise_docs.py. This brings the two nearly-identical handlers into alignment. Risk: I did not verify whether existing callers rely on serving non-.md files (e.g. module_tree.json/metadata.json are loaded separately via file_manager.load_json, not through this served-file path, so this should be safe) — the reviewer should confirm no legitimate non-.md filenames are ever routed through this endpoint before merging.

🤖 Prompt for AI agents
In codewiki/src/fe/routes.py around line 245, review and complete this code-review fix: serve_generated_docs path-traversal guard only checks parents/equality, not symlink resolution, and differs from visualise_docs.py's is_relative_to check.
What the draft fix changed: In `serve_generated_docs` (routes.py), replaced the `docs_path_resolved != file_path and docs_path_resolved not in file_path.parents` containment check with `file_path.is_relative_to(docs_path_resolved)`, matching the approach used in visualise_docs.py's `serve_doc`. Added a `.md` extension allowlist check on `filename` before resolving paths, and wrapped the `.resolve()` calls plus containment check in a try/except that raises `HTTPException(400, "Invalid file path")` on any exception, mirroring the defensive try/except pattern in visualise_docs.py. This brings the two nearly-identical handlers into alignment. Risk: I did not verify whether existing callers rely on serving non-`.md` files (e.g. `module_tree.json`/`metadata.json` are loaded separately via `file_manager.load_json`, not through this served-file path, so this should be safe) — the reviewer should confirm no legitimate non-`.md` filenames are ever routed through this endpoint before merging.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 75 medium — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(adhoc-sweep-fixes): 3 review findings across 3 files fix(adhoc-sweep-fixes): CU-86akn96pk 3 review findings across 3 files Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants