Skip to content

fix: AI review failed silently — octokit.issues namespace undefined#22

Merged
avrabe merged 1 commit intomainfrom
fix/ai-review-use-request-form
Apr 25, 2026
Merged

fix: AI review failed silently — octokit.issues namespace undefined#22
avrabe merged 1 commit intomainfrom
fix/ai-review-use-request-form

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 25, 2026

Root cause

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 (pm2 logs temper) confirm this hitting PRs #209, #210, … #213 in pulseengine/rivet. Zero AI review comments on any pulseengine PR since ~2026-03.

src/ai-review.js called octokit.issues.listComments, .updateComment, and .createComment. Probot v14's bundled Octokit 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 already uses.

Fix

Replace the three octokit.issues.X calls in ai-review.js with the .request() form. 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

  • All 698 tests pass
  • eslint clean
  • After merge + self-update: open any non-bot PR in any pulseengine repo. The AI review comment should appear within ~5 min.
  • If it still doesn't land, the second remaining cause is the Ollama timeout — qwen2.5-coder:3b on the netcup VPS sometimes exceeds the 300s `ai_review.timeout`. That'll be a tuning follow-up.

Risk & rollout

  • Risk: low. Pure call-shape change. Same endpoints, same params.
  • Rollout: self-update on merge.

🤖 Generated with Claude Code

…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>
@avrabe avrabe merged commit a9b8e6f into main Apr 25, 2026
5 checks passed
@avrabe avrabe deleted the fix/ai-review-use-request-form branch April 25, 2026 23:17
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