[PR #35] [MERGED] fix: return proper HTTP status codes for delete/undelete errors #222

Closed
opened 2026-02-15 17:16:21 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/35
Author: @sergical
Created: 1/25/2026
Status: Merged
Merged: 2/14/2026
Merged by: @steipete

Base: mainHead: fix/delete-error-handling


📝 Commits (8)

  • de2542e fix: return proper HTTP status codes for delete/undelete errors
  • f1a5254 fix(cli): use proper Error objects in abort timeouts
  • 1ae0498 test: add e2e test for delete error handling
  • eb9a67f fix: use Error for timeout abort in e2e helper
  • 0e83ba0 fix(api): centralize v1 soft-delete error mapping
  • 802ee58 chore(cli): align http client with main
  • bafd17b test(api): cover v1 soft-delete error mapping
  • 182ec87 test(api): reposition soft-delete mapping test

📊 Changes

4 files changed (+626 additions, -64 deletions)

View changed files

📝 convex/httpApiV1.handlers.test.ts (+447 -5)
📝 convex/httpApiV1.ts (+25 -8)
📝 e2e/clawdhub.e2e.test.ts (+46 -1)
📝 packages/clawdhub/src/http.ts (+108 -50)

📄 Description

Problem

The clawdhub delete <slug> command returns confusing error messages. Two issues were found:

Issue 1: API returns 401 for all errors

The delete/undelete handlers catch ALL errors and return Unauthorized, masking real issues like Skill not found or Forbidden.

Issue 2: CLI timeout throws strings instead of Errors

When requests timeout, controller.abort('Timeout') passes a string. This causes pRetry to throw:

Non-error was thrown: "Timeout". You should only throw errors.

Reproduction

clawdhub delete some-skill --yes
# ✖ Non-error was thrown: "Timeout". You should only throw errors.
# or
# ✖ Unauthorized  (when server error is masked)

Fixes

1. API Error Handling (convex/httpApiV1.ts)

Updated error handling in 4 handlers to return appropriate HTTP status codes:

  • skillsDeleteRouterV1Handler
  • skillsPostRouterV1Handler (undelete)
  • soulsDeleteRouterV1Handler
  • soulsPostRouterV1Handler (undelete)

Before: All errors → 401 Unauthorized
After:

  • 401: Authentication failures
  • 403: Authorization failures (not owner/admin/moderator)
  • 404: Skill/soul/user not found
  • 400: Other errors with descriptive message

2. CLI Timeout Handling (packages/clawdhub/src/http.ts)

Fixed 3 occurrences of controller.abort('Timeout') to use proper Error objects:

  • apiRequest (line 57)
  • apiRequestForm (line 106)
  • downloadZip (line 141)

Before: controller.abort('Timeout') — throws string
After: controller.abort(new Error('Timeout')) — throws Error

Fixes #34


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/35 **Author:** [@sergical](https://github.com/sergical) **Created:** 1/25/2026 **Status:** ✅ Merged **Merged:** 2/14/2026 **Merged by:** [@steipete](https://github.com/steipete) **Base:** `main` ← **Head:** `fix/delete-error-handling` --- ### 📝 Commits (8) - [`de2542e`](https://github.com/openclaw/clawhub/commit/de2542e39199fabce32b3ab00aee5bb98ed28c4c) fix: return proper HTTP status codes for delete/undelete errors - [`f1a5254`](https://github.com/openclaw/clawhub/commit/f1a525475502c10088c7d21e8ff56aa507c016a3) fix(cli): use proper Error objects in abort timeouts - [`1ae0498`](https://github.com/openclaw/clawhub/commit/1ae04985959a4061461fa055a01df48da9d41d27) test: add e2e test for delete error handling - [`eb9a67f`](https://github.com/openclaw/clawhub/commit/eb9a67f2af8c2502a66bad9e49bf4088260397f9) fix: use Error for timeout abort in e2e helper - [`0e83ba0`](https://github.com/openclaw/clawhub/commit/0e83ba00b9c8a2d5cb72d4a4b98d6518c03a645c) fix(api): centralize v1 soft-delete error mapping - [`802ee58`](https://github.com/openclaw/clawhub/commit/802ee58054fca80d48f8a40a6e3f79753f29c7c8) chore(cli): align http client with main - [`bafd17b`](https://github.com/openclaw/clawhub/commit/bafd17b00ad21983ed267763c0b137dea1eb1e57) test(api): cover v1 soft-delete error mapping - [`182ec87`](https://github.com/openclaw/clawhub/commit/182ec8741ff21b39a43c558021bd436f4c40a84d) test(api): reposition soft-delete mapping test ### 📊 Changes **4 files changed** (+626 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `convex/httpApiV1.handlers.test.ts` (+447 -5) 📝 `convex/httpApiV1.ts` (+25 -8) 📝 `e2e/clawdhub.e2e.test.ts` (+46 -1) 📝 `packages/clawdhub/src/http.ts` (+108 -50) </details> ### 📄 Description ## Problem The `clawdhub delete <slug>` command returns confusing error messages. Two issues were found: ### Issue 1: API returns 401 for all errors The delete/undelete handlers catch ALL errors and return `Unauthorized`, masking real issues like `Skill not found` or `Forbidden`. ### Issue 2: CLI timeout throws strings instead of Errors When requests timeout, `controller.abort('Timeout')` passes a string. This causes pRetry to throw: ``` Non-error was thrown: "Timeout". You should only throw errors. ``` ## Reproduction ```bash clawdhub delete some-skill --yes # ✖ Non-error was thrown: "Timeout". You should only throw errors. # or # ✖ Unauthorized (when server error is masked) ``` ## Fixes ### 1. API Error Handling (convex/httpApiV1.ts) Updated error handling in 4 handlers to return appropriate HTTP status codes: - `skillsDeleteRouterV1Handler` - `skillsPostRouterV1Handler` (undelete) - `soulsDeleteRouterV1Handler` - `soulsPostRouterV1Handler` (undelete) **Before:** All errors → 401 Unauthorized **After:** - 401: Authentication failures - 403: Authorization failures (not owner/admin/moderator) - 404: Skill/soul/user not found - 400: Other errors with descriptive message ### 2. CLI Timeout Handling (packages/clawdhub/src/http.ts) Fixed 3 occurrences of `controller.abort('Timeout')` to use proper Error objects: - `apiRequest` (line 57) - `apiRequestForm` (line 106) - `downloadZip` (line 141) **Before:** `controller.abort('Timeout')` — throws string **After:** `controller.abort(new Error('Timeout'))` — throws Error Fixes #34 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:21 -05:00
yindo closed this issue 2026-02-15 17:16:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#222