GitHubPromptGenerator: splitRepository validation runs after the network search, hiding the clear error behind an API failure
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- github, typescript
Research direction
Start in src/prompt-generators/github.ts and trace GitHubPromptGenerator.generate, splitRepository, and github.searchIssues. Check the existing tests or test setup for generator validation and network calls. Done means malformed repository values produce splitRepository’s clear error before searchIssues makes any request.
Written by the indexing model from the issue text.
Description
Observed behavior
In src/prompt-generators/github.ts, GitHubPromptGenerator.generate performs the GitHub search before validating the repository value:
async *generate(loopState: LoopState): AsyncIterable<Prompt> {
const github = new GitHub(this.#task.github);
const issues = await github.searchIssues(this.#task.search); // <-- network call first
const repository = this.#task.search.repository;
const [owner, repo] = splitRepository(repository); // <-- validation second
...
}
If repository is malformed (e.g. 'octocat', 'octocat/', 'owner/repo/extra', or an empty string), the helpful local error from splitRepository
GitHub repository must be in owner/repo form: octocat
never gets a chance to fire on its own. The library first builds a query like is:open repo:octocat is:issue, calls /search/issues, and either:
- Wastes the HTTP call (and a rate-limit unit) on a query GitHub returns zero results for, or
- Surfaces a confusing
GitHub API error 422: Validation Failedif GitHub rejects the qualifier, with no hint that the root cause is therepositoryconfig field.
splitRepository then throws afterwards (or never throws if the search returned 422 first), so callers see either zero results or an opaque GitHub API error rather than the clear, actionable error the helper was designed to produce.
Expected behavior
A malformed repository should fail fast with splitRepository's message, before any network call is made, so the user is pointed straight at the bad config field.
Minimal reproduction
import { GitHubPromptGenerator } from 'loop-the-loop/prompt-generators/github';
import { LoopState } from 'loop-the-loop/util/loop-state';
const gen = await GitHubPromptGenerator.create({
search: { repository: 'octocat', query: 'is:open' },
promptTemplate: 'Review {{id}}',
});
const loopState = await LoopState.create('/tmp/state.json');
for await (const _ of (gen as any).generate(loopState)) {
// never reached - but only after a wasted network call
}
Suggested fix
Validate repository before calling searchIssues. Either:
- Move the
splitRepositorycall ahead ofgithub.searchIssues(...)ingenerate, or - Better: validate in the constructor (or in
normalizeGitHubTaskConfig) so a misconfigured task is rejected before any generator iteration begins.
Option 2 also brings it into line with where other config invariants are enforced.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from joewalker/loop-the-loop
-
bug S4
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
joewalker/loop-the-loop#88 ·
-
Git exec(): child killed by a signal rejects with new Error('') and loses the signal information Openbug S3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
joewalker/loop-the-loop#84 ·
-
bug S3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
joewalker/loop-the-loop#83 ·
-
bug S3
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
joewalker/loop-the-loop#82 ·
-
bug S4
Difficulty 1/5 Under an hour Newbie friendliness 90/100
joewalker/loop-the-loop#79 ·
All issues in joewalker/loop-the-loop
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·