discourse/lib/reviewable
Alan Guo Xiang Tan 3324fe4fef
FIX: ensure remove_reviewable_ids is always an array (#37131)
What is the problem?

The review queue throws a JavaScript error when processing MessageBus
updates:

```
MESSAGE BUS FAIL: callback /reviewable_action caused exception
TypeError: Cannot read properties of undefined (reading 'includes')
```

The bug flow is:

1. `Reviewable::PerformResult#initialize` only sets
`@remove_reviewable_ids`
   when `success?` is true, leaving it nil otherwise
2. `ReviewablePerformResultSerializer` serializes nil as JSON null
3. MessageBus publishes this to `/reviewable_action` channel
4. The JS `_updateStatus` callback in `ReviewableItem` receives data
with
   `remove_reviewable_ids` as null/undefined
5. Calling `.includes()` on null throws TypeError

What is the solution?

Always initialize `@remove_reviewable_ids` as an array in
`Reviewable::PerformResult#initialize` (empty for failures, containing
the reviewable id for successes). Also add defensive optional chaining
in the JS `ReviewableItem#_updateStatus` callback and update the truthy
check in `ReviewableItem#_performResult` to verify array length since
`[]` is truthy in JavaScript.
2026-01-15 10:35:59 +08:00
..
actions.rb DEV: Log Reviewable actions (#36076) 2025-11-20 13:41:40 +11:00
collection.rb DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073) 2025-10-06 16:11:01 +02:00
conversation.rb
editable_fields.rb
perform_result.rb FIX: ensure remove_reviewable_ids is always an array (#37131) 2026-01-15 10:35:59 +08:00