Skip to content

Fix admin mark_failed and add_note claim actions#305

Merged
GsCommand merged 1 commit into
mainfrom
codex/fix-admin_claim_action_failed-behavior
May 23, 2026
Merged

Fix admin mark_failed and add_note claim actions#305
GsCommand merged 1 commit into
mainfrom
codex/fix-admin_claim_action_failed-behavior

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Motivation

  • Fix occurrences of ADMIN_CLAIM_ACTION_FAILED when invoking admin actions on an approved claim by aligning frontend payload keys and backend handling for mark_failed and add_note.
  • Ensure mark_failed and add_note behave deterministically with required inputs and produce appropriate events and transitions without weakening the status machine.
  • Provide safer, more informative server logging and client error rendering to aid debugging in non-production without leaking secrets.

Description

  • Update api/admin/claim-action.js to require reason for mark_failed and notes for add_note, allow mark_failed from any non-live status, update claim_requests (status = 'failed', last_error, last_error_at) for failures, and insert matching claim.failed event and a claim_status_transitions record with metadata.
  • Change add_note to preserve claim status, append/update admin_notes, and insert a claim.note_added event (message + json) without inserting a status transition.
  • Improve error handling by logging { message, code, action, claimId, currentStatus } on unexpected failures and include a debug object in the JSON response only when NODE_ENV !== 'production'.
  • Align public/admin/claims.html to send reason for mark_failed and notes for add_note, and render API errors inline as Action failed: <status> — <error> with optional Details: <debug.message> when present.
  • Add and expand tests in tests/api-admin-claims.test.js to cover mark_failed success/failure semantics, event and transition writes, add_note behavior, and frontend payload key expectations.

Testing

  • Ran the full test suite with npm test and all tests passed (77 tests passed after changes).
  • Ran example checks with cd examples/webhook-auto-verify && npm run check and the check succeeded.
  • New/updated unit tests specifically covering mark_failed and add_note behaviors passed in the automated test run.

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commandlayer-commandlayer-org Ready Ready Preview, Comment May 23, 2026 8:37pm
commandlayer-org Ready Ready Preview, Comment May 23, 2026 8:37pm
commandlayer-org111 Ready Ready Preview, Comment May 23, 2026 8:37pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant