Skip to content

Fix dispatch and verify 500 errors#103

Merged
mkreyman merged 1 commit intomasterfrom
fix/dispatch-500-verify-500
Apr 13, 2026
Merged

Fix dispatch and verify 500 errors#103
mkreyman merged 1 commit intomasterfrom
fix/dispatch-500-verify-500

Conversation

@mkreyman
Copy link
Copy Markdown
Owner

Summary

Two 500 errors found by the independent verification agent:

  • Dispatch 500: POST /dispatches crashed with Postgrex.Error when agent already had an active key (unique constraint api_keys_one_role_per_agent_idx not declared in changeset). Now returns 422 with field error.
  • Verify 500: POST /stories/:id/verify crashed with CaseClauseError when tenant has audit key but no capability token provided (:missing_capability not handled). Added catch-all error propagation to fallback controller.

Test plan

  • 2263 tests pass, dialyzer clean
  • POST /stories/:id/verify on verified story → informative error (not 500)
  • POST /dispatches with existing agent → 422 (not 500)

🤖 Generated with Claude Code

Bug 1: POST /dispatches crashed with Postgrex.Error when the agent
already had an active key. Added unique_constraint declaration to
ApiKey changeset so constraint violations produce 422 instead of 500.

Bug 2: POST /stories/:id/verify crashed with CaseClauseError when
the tenant has an audit key but no capability token was provided.
Added catch-all error clause to propagate to the fallback controller.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mkreyman mkreyman merged commit 72f59c1 into master Apr 13, 2026
6 checks passed
@mkreyman mkreyman deleted the fix/dispatch-500-verify-500 branch April 13, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant