Skip to content

fix: validate repo format before splitting in all tool functions#184

Merged
ichoosetoaccept merged 1 commit intomainfrom
02-18-fix-validate-repo-format-before-splitting-in-all-tool-functions
Feb 18, 2026
Merged

fix: validate repo format before splitting in all tool functions#184
ichoosetoaccept merged 1 commit intomainfrom
02-18-fix-validate-repo-format-before-splitting-in-all-tool-functions

Conversation

@ichoosetoaccept
Copy link
Member

Description

Checklist

  • Tests added/updated
  • Documentation updated (if applicable)
  • poe check passes
  • Commit messages follow conventional commits

Related Issues

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps
Copy link

greptile-apps bot commented Feb 18, 2026

Greptile Summary

Extracts a new parse_repo function in gh.py that validates "owner/repo" format (including empty-component checks) and replaces 7 raw repo.split("/", 1) calls across the tool modules with gh.parse_repo(repo). This ensures consistent, early validation with clear error messages instead of silent malformed API paths.

  • New parse_repo() centralizes repo string validation with GhError on invalid input
  • All tool functions in comments.py, issues.py, and stack.py now use the shared validator
  • Test suite covers valid input, missing slash, empty string, empty owner, and empty repo cases
  • Note: get_repo_info() in gh.py:314 still uses a raw split("/", 1) — acceptable since its input comes from the gh CLI, but could be updated for consistency in a follow-up

Confidence Score: 4/5

  • This PR is safe to merge — it adds input validation without changing any existing behavior for valid inputs.
  • The changes are straightforward, well-tested, and purely additive in terms of validation. One minor style concern exists around multi-slash inputs being accepted, but it doesn't affect existing functionality.
  • src/codereviewbuddy/gh.py — the parse_repo function's split("/", 1) behavior with multi-slash inputs could be tightened.

Important Files Changed

Filename Overview
src/codereviewbuddy/gh.py Adds new parse_repo function that centralizes "owner/repo" validation with empty-component checks. Minor: still uses split("/", 1) which accepts multi-slash inputs.
src/codereviewbuddy/tools/comments.py Three call sites updated from raw repo.split("/", 1) to gh.parse_repo(repo). Straightforward, correct substitution.
src/codereviewbuddy/tools/issues.py One call site updated to use gh.parse_repo(repo). Clean, no issues.
src/codereviewbuddy/tools/stack.py Three call sites updated to use gh.parse_repo(repo). Clean, no issues.
tests/test_gh.py Adds TestParseRepo class with 5 test cases covering valid input, missing slash, empty string, empty owner, and empty repo. Good coverage of the new function.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Tool function called with repo param"] --> B{"repo provided?"}
    B -- Yes --> C["gh.parse_repo(repo)"]
    B -- No --> D["gh.get_repo_info(cwd)"]
    C --> E{"'/' in repo?"}
    E -- No --> F["Raise GhError"]
    E -- Yes --> G["split('/', 1)"]
    G --> H{"owner and repo_name non-empty?"}
    H -- No --> F
    H -- Yes --> I["Return (owner, repo_name)"]
    D --> I
    I --> J["Proceed with GitHub API calls"]
Loading

Last reviewed commit: 6c2862b

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@ichoosetoaccept ichoosetoaccept force-pushed the 02-18-fix-validate-repo-format-before-splitting-in-all-tool-functions branch from ef43b78 to 6c2862b Compare February 18, 2026 15:56
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@ichoosetoaccept ichoosetoaccept merged commit ed1f871 into main Feb 18, 2026
12 checks passed
@ichoosetoaccept ichoosetoaccept deleted the 02-18-fix-validate-repo-format-before-splitting-in-all-tool-functions branch February 18, 2026 16:03
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.

1 participant