Commit f364d8c
authored
🤖 Fix browser API handling of failed Results without error property (#393)
_Generated with `cmux`_
## Problem
The web main-server's `HttpIpcMainAdapter` was incorrectly handling
failed Results that don't have an `error` property.
The check required both `success === false` AND `'error' in result`:
```typescript
if (
result &&
typeof result === "object" &&
"success" in result &&
result.success === false &&
"error" in result // <-- This line was the bug
) {
res.json(result);
return;
}
res.json({ success: true, data: result });
```
When a handler returned `{ success: false }` without an `error`
property, the check failed and the result was incorrectly wrapped as:
```json
{
"success": true,
"data": { "success": false }
}
```
This broke error handling in the frontend - errors from operations like
force workspace deletion weren't being properly communicated.
## Solution
Remove the `'error' in result` requirement. Any Result with `success:
false` should be passed through directly, regardless of whether it has
an `error` property.
## Testing
Added test case in `api.test.ts` to verify Results without error
property are handled correctly.1 parent 181a2e9 commit f364d8c
2 files changed
+22
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
135 | 156 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
| 39 | + | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
0 commit comments