Uh oh!
There was an error while loading. Please reload this page.
fix(repos): normalize whitespace in repo identifiers before lookup - #261
Conversation
Previously, inputs like ' usedetail/cli' or 'usedetail / cli' passed `validate_owner_repo_format` (which used `.trim().is_empty()` purely for emptiness checking) but were then compared verbatim against `r.full_name`. The exact-match failed and the user got the misleading 'Repository not found. Make sure you have access …' hint for what was actually a whitespace typo. Trim the identifier (and each half of an owner/repo pair) before matching. The 'not found' error now quotes the normalized form so the hint is accurate. Fixes#230. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eaf2875 to
e7ffecaCompare| let normalized = identifier | ||
| .split('/') | ||
| .map(str::trim) | ||
| .collect::<Vec<_>>() | ||
| .join("/"); |
There was a problem hiding this comment.
📝 Info: Redundant trim in normalization after validate_owner_repo_format
The normalization at src/utils/repos.rs:84-88 splits on / and trims each part. However, validate_owner_repo_format at line 37 already uses .trim() to check for emptiness but does not reject parts that merely contain whitespace (e.g., "use detail/cli" would pass validation and then normalization would produce "use detail/cli" — the inner space is preserved, which is correct). The double-trim between identifier = repo_identifier.trim() (line 81) and the per-part .map(str::trim) (line 86) is intentional: outer trim handles leading/trailing whitespace, while per-part trim handles whitespace around the slash like "owner / repo". This is not a bug, just worth noting the two-stage trimming design.
Was this helpful? React with 👍 or 👎 to provide feedback.
Uh oh!
There was an error while loading. Please reload this page.
## Summary Patch release rolling up the seven fixes merged since 0.2.1: - fix(bugs): print empty-results hint when `--vulns` alone yields no matches (#264) - fix(datetime): floor sub-second negative timestamps instead of snapping to epoch (#262) - chore(deps): bump rustls-webpki to 0.103.13 for RUSTSEC-2026-0104 (#263) - fix(repos): normalize whitespace in repo identifiers before lookup (#261) - fix(git): parse GitHub remotes with embedded http(s) credentials (#260) - fix(auth): redirect browser and surface OAuth errors on PKCE callback failure (#258) - refactor(config): rewrite `update_config` through the locked handle (#257) On merge, the release workflow will tag `v0.2.2` and publish platform artifacts via cargo-dist. ## Test plan - [x] `cargo build` succeeds with version 0.2.2 - [ ] Tag `v0.2.2` is created on merge and release workflow publishes artifacts 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/usedetail/cli/pull/265" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review"> </picture> </a> <!-- devin-review-badge-end --> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Inputs like
' usedetail/cli'or'usedetail / cli'passedvalidate_owner_repo_format(which used.trim().is_empty()only for emptiness checks) but were then compared verbatim againstr.full_name. The exact match failed and users got a misleading "Repository not found. Make sure you have access …" error for what was actually a whitespace typo.Trim the identifier, and trim each half of an
owner/repopair, before matching. The "not found" error now quotes the normalized form so the hint itself is accurate.Stacked on
#260 (fix for GitHub remote parsing with embedded credentials). Base branch is
siyer/fix-parse-github-remote-creds; the diff against main is just the repos.rs change.Test plan
cargo test --lib utils::repos— 22 pass, including 4 new cases (leading/trailing whitespace, whitespace around slash, bare-name trim, normalized error message)cargo clippy -- -D warningscleancargo fmt --checkcleanFixes#230.
🤖 Generated with Claude Code