Conversation
Review Summary by QodoHash binary skill files with SHA256
WalkthroughsDescription• Add SHA256 hashing for binary skill files • Replace generic message with hash-based identification • Enable binary file content verification and comparison Diagramflowchart LR
A["Binary File Read Error"] -->|"Generate SHA256 hash"| B["Hash-based Content"]
B -->|"Replace generic message"| C["Binary file. Hash: {hexdigest}"]
File Changes1. src/agent_scan/skill_client.py
|
Code Review by Qodo
1. traverse_skill_tree() too long
|
| content = f.read() | ||
| except UnicodeDecodeError: | ||
| logger.exception(f"Error reading file: {file}. The file is not a bianry") | ||
| content = "Binary file. No content available." | ||
| with open(os.path.expanduser(full_path), "rb") as f: | ||
| content_hash = hashlib.sha256(f.read()).hexdigest() | ||
| content = f"Binary file. Hash: {content_hash}" | ||
| resources.append( | ||
| Resource( | ||
| name=file, |
There was a problem hiding this comment.
1. traverse_skill_tree() too long 📘 Rule violation ⚙ Maintainability
traverse_skill_tree() is ~60 lines long, exceeding the ≤40 SLOC limit, making it harder to maintain and safely extend. This PR modifies the function further without extracting helpers.
Agent Prompt
## Issue description
`traverse_skill_tree()` exceeds the 40-line function length limit and was further expanded/modified in this PR.
## Issue Context
Large functions are harder to test and maintain; this function currently handles traversal, file-type branching, text reading, binary handling, and object construction.
## Fix Focus Areas
- src/agent_scan/skill_client.py[78-137]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| except UnicodeDecodeError: | ||
| logger.exception(f"Error reading file: {file}. The file is not a bianry") | ||
| content = "Binary file. No content available." | ||
| with open(os.path.expanduser(full_path), "rb") as f: | ||
| content_hash = hashlib.sha256(f.read()).hexdigest() | ||
| content = f"Binary file. Hash: {content_hash}" |
There was a problem hiding this comment.
2. No regression test for hash 📘 Rule violation ☼ Reliability
The PR changes binary resource descriptions to include a SHA-256 hash, but no test asserts this new behavior. Without an assertion, the change can silently regress.
Agent Prompt
## Issue description
Add a regression/unit test that asserts binary files are represented with a deterministic SHA-256 hash in `Resource.description`.
## Issue Context
The code now sets `content = f"Binary file. Hash: {content_hash}"` for binary files; existing tests exercise skill inspection but do not assert this new output.
## Fix Focus Areas
- src/agent_scan/skill_client.py[121-128]
- tests/v4compatibility/test_inspect.py[119-121]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| with open(os.path.expanduser(full_path), "rb") as f: | ||
| content_hash = hashlib.sha256(f.read()).hexdigest() | ||
| content = f"Binary file. Hash: {content_hash}" |
There was a problem hiding this comment.
3. Binary hash errors unhandled 🐞 Bug ☼ Reliability
In traverse_skill_tree(), the fallback path for binary files opens and reads the file in binary mode without any error handling, so PermissionError/ENOENT/etc. will bubble up and fail the entire skill scan. Previously the UnicodeDecodeError fallback always produced a placeholder string and continued.
Agent Prompt
### Issue description
`traverse_skill_tree()` catches `UnicodeDecodeError` from the UTF-8 read, but then performs a second `open(..., "rb")` + read/hash without a protective `try/except`. Any `OSError` (e.g., `PermissionError`, `FileNotFoundError` due to concurrent changes) will propagate and fail the scan.
### Issue Context
This code runs during skill scanning (`inspect_skill()` calls `traverse_skill_tree()`), so a single unreadable binary should not abort the whole scan.
### Fix Focus Areas
- src/agent_scan/skill_client.py[120-135]
### Expected fix
- Wrap the binary open/hash in a `try/except (OSError, Exception)`.
- On failure, log (prefer `logger.warning`/`logger.exception` with clear message) and set `content` to a safe placeholder like `"Binary file. Hash unavailable."` so traversal continues.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.