fix: AI review failed silently — octokit.issues namespace undefined#22
Merged
fix: AI review failed silently — octokit.issues namespace undefined#22
Conversation
…t runtime
## Root cause
On the deployed bot, every `pull_request.opened` event triggered an AI review
that immediately failed with `Cannot read properties of undefined (reading
'listComments')` and `(reading 'createComment')`. Production logs show this
hitting PRs #209, #210, … #213 in pulseengine/rivet. Zero AI review comments
have appeared on any pulseengine PR since at least 2026-03.
`src/ai-review.js` called `octokit.issues.listComments`, `.updateComment`,
and `.createComment`. Probot v14's bundled Octokit (`@octokit/rest@22`) in
the `pull_request.opened` event context does **not** expose the `.issues`
namespace plugin. The same `context.octokit` works through `.request(route,
params)` (which is what every other call site in the codebase uses).
## Fix
Replace the three `octokit.issues.X` calls with the `.request()` form:
| Was | Now |
|---|---|
| `octokit.issues.listComments({...})` | `octokit.request('GET /repos/{owner}/{repo}/issues/{issue_number}/comments', {...})` |
| `octokit.issues.updateComment({...})` | `octokit.request('PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}', {...})` |
| `octokit.issues.createComment({...})` | `octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', {...})` |
The test mock retrofit dispatches `.request(route, params)` into the existing
namespaced `jest.fn()`s when the route matches one of those three — so all
166 ai-review test assertions still apply unchanged.
## Test plan
- [x] All 698 tests pass
- [x] eslint clean
- [ ] After merge + self-update: open a draft PR in pulseengine/temper (or
any non-bot PR in another pulseengine repo). The AI review comment
should appear within ~5 min. If it still doesn't, the second remaining
cause is the Ollama timeout — `qwen2.5-coder:3b` on the netcup VPS
sometimes exceeds the 300s `ai_review.timeout`.
## Risk & rollout
- Risk: low. Pure call-shape change. Same endpoints, same params.
- Rollout: self-update on merge. Confirmation = AI review comment lands on
the next PR opened in any pulseengine repo.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Every
pull_request.openedevent triggered an AI review that immediately failed withCannot read properties of undefined (reading 'listComments')and(reading 'createComment'). Production logs (pm2 logs temper) confirm this hitting PRs #209, #210, … #213 inpulseengine/rivet. Zero AI review comments on any pulseengine PR since ~2026-03.src/ai-review.jscalledoctokit.issues.listComments,.updateComment, and.createComment. Probot v14's bundled Octokit in thepull_request.openedevent context does not expose the.issuesnamespace plugin. The samecontext.octokitworks through.request(route, params)— which is what every other call site in the codebase already uses.Fix
Replace the three
octokit.issues.Xcalls inai-review.jswith the.request()form. The test mock retrofit dispatches.request(route, params)into the existing namespacedjest.fn()s when the route matches one of those three — so all 166 ai-review test assertions still apply unchanged.Test plan
qwen2.5-coder:3bon the netcup VPS sometimes exceeds the 300s `ai_review.timeout`. That'll be a tuning follow-up.Risk & rollout
🤖 Generated with Claude Code