refactor: standardise error response format across API controllers #65

Open
Charon wants to merge 1 commit from feat/standardise-error-responses into dev
Member

Summary

  • Created HasStandardApiResponses trait in Concerns/ with consistent error format: {"success": false, "error": "Human-readable message", "code": "MACHINE_READABLE_CODE"}
  • Applied trait to EntitlementApiController, EntitlementWebhookController, and WorkspaceController
  • Replaced all ad-hoc response()->json() error/success calls with trait methods
  • Updated EntitlementApiTest assertions to match the new code field

Fixes #20

Test plan

  • Run composer test to verify all existing tests pass with updated assertions
  • Verify error responses include success, error, and code fields
  • Verify success responses include success: true
## Summary - Created `HasStandardApiResponses` trait in `Concerns/` with consistent error format: `{"success": false, "error": "Human-readable message", "code": "MACHINE_READABLE_CODE"}` - Applied trait to `EntitlementApiController`, `EntitlementWebhookController`, and `WorkspaceController` - Replaced all ad-hoc `response()->json()` error/success calls with trait methods - Updated `EntitlementApiTest` assertions to match the new `code` field Fixes #20 ## Test plan - [ ] Run `composer test` to verify all existing tests pass with updated assertions - [ ] Verify error responses include `success`, `error`, and `code` fields - [ ] Verify success responses include `success: true`
Charon added 1 commit 2026-03-24 13:32:13 +00:00
Add HasStandardApiResponses trait with consistent error format:
{"success": false, "error": "Human-readable message", "code": "MACHINE_READABLE_CODE"}

Applied to EntitlementApiController, EntitlementWebhookController,
and WorkspaceController. Updated tests to assert the new format.

Fixes #20

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/standardise-error-responses:feat/standardise-error-responses
git checkout feat/standardise-error-responses

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout dev
git merge --no-ff feat/standardise-error-responses
git checkout feat/standardise-error-responses
git rebase dev
git checkout dev
git merge --ff-only feat/standardise-error-responses
git checkout feat/standardise-error-responses
git rebase dev
git checkout dev
git merge --no-ff feat/standardise-error-responses
git checkout dev
git merge --squash feat/standardise-error-responses
git checkout dev
git merge --ff-only feat/standardise-error-responses
git checkout dev
git merge feat/standardise-error-responses
git push origin dev
Sign in to join this conversation.
No description provided.