fix: normalize DOCS_SUBFOLDER trailing slash before CWD comparison - #79
Conversation
DOCS_SUBFOLDER set with a trailing slash (e.g. "docs/") caused the CWD
comparison in _get_effective_subfolder() to fail: git rev-parse returns
"docs/" which gets rstripped to "docs", but the env var was compared
as-is ("docs/" != "docs"). The mismatch kept the subfolder prefix in
pathspecs, causing the double-prefix bug that made all ref reads empty.
Confirmed by debug logging from redhat-community-ai-tools#76:
CWD prefix 'docs' != DOCS_SUBFOLDER '***', keeping prefix
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 7:02 AM UTC · Completed 7:14 AM UTC Commit: |
Addresses review feedback on the trailing slash fix: - Normalize at the boundary: strip trailing slash in entrypoint.sh so all 8 Python callsites get a clean value - Normalize more liberally: use os.path.normpath in _get_effective_subfolder as defense-in-depth, handling ./docs, /docs, and docs/ uniformly - Add pathspec-level regression test: asserts get_folder_doc_hashes_from_ref builds the correct ls-tree pathspec (["--", "commands"] not ["--", "docs//commands"]) when DOCS_SUBFOLDER has a trailing slash - Test state hygiene: autouse fixture for _last_msg cleanup - Add ./docs normalization test case Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ReviewFindingsLow
Labels: PR fixes a bug in Python path normalization logic within the GitHub Action entrypoint Previous runReviewReason: stale-head The review agent reviewed commit |
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 7:15 AM UTC · Completed 7:27 AM UTC Commit: |
| """ | ||
| docs_subfolder = os.environ.get("DOCS_SUBFOLDER", "") | ||
| raw = os.environ.get("DOCS_SUBFOLDER", "") | ||
| docs_subfolder = os.path.normpath(raw).strip("/") if raw.strip() else "" |
There was a problem hiding this comment.
[low] edge-case
When DOCS_SUBFOLDER is set to "." or "./", os.path.normpath(raw).strip("/") produces ".", which is truthy and passes the emptiness guard. The function compares "." against git rev-parse --show-prefix output (empty at repo root), returning "." as effective subfolder. Downstream pathspecs like "./commands" work in git but behavior is inconsistent with intent.
Suggested fix: Add a guard after normpath: if docs_subfolder == ".": docs_subfolder = ""
|
🤖 Finished Retro · ✅ Success · Started 7:35 AM UTC · Completed 7:47 AM UTC Commit: |
Retro: PR #79 — fix: normalize DOCS_SUBFOLDER trailing slashVerdict: Workflow went well. No new proposals — all improvement areas are already tracked by existing issues. Timeline
What went well
Observations (evidence for existing issues)
|
Summary
DOCS_SUBFOLDERset with a trailing slash (e.g.docs/) caused_get_effective_subfolder()to fail its CWD comparison:git rev-parse --show-prefixreturnsdocs/which getsrstrip("/")todocs, but the env var was compared as-is —"docs" != "docs/"docs/docs/...) that made all ref-based reads return emptyDOCS_SUBFOLDERat the start of_get_effective_subfolder()Confirmed by debug logging added in #76:
Test plan
TestGetEffectiveSubfolderclass with 4 tests:🤖 Generated with Claude Code