Skip to content

fix: restore agent API-key auth for task comments/execution#73

Merged
kalinon merged 1 commit intomainfrom
fix/task-route-api-key-auth
Mar 19, 2026
Merged

fix: restore agent API-key auth for task comments/execution#73
kalinon merged 1 commit intomainfrom
fix/task-route-api-key-auth

Conversation

@moltar-bot
Copy link
Copy Markdown
Contributor

@moltar-bot moltar-bot commented Mar 19, 2026

Summary

  • fix tasks route optional auth for machine-agent API keys (mba_*)
  • align hashing with auth middleware (Node crypto SHA-256 -> key_hash lookup)
  • allow API-key-authenticated agents to create task comments (nullable author_id) while preserving agent metadata in task logs

Root cause

tasks.js used a different API-key lookup path (encode(digest(...))) than auth.js (crypto.createHash('sha256')). In practice this left req.user unset for strict endpoints (/tasks/:id/comments, /tasks/:id/execution), causing 401 Authorization required.

Validation

  • npm run -w ./api lint -- src/routes/tasks.js
  • npm run -w ./api test:run -- src/routes/__tests__/tasks.edge-cases.test.js
  • Live verification after deploy:
    • agent added [ACK] and [DONE] comments
    • task execution events recorded (AGENT_PROGRESS, AGENT_DONE)
    • task metadata updated (last_agent_id, last_session_key, last_reported_at)

- align tasks optionalAuth API-key lookup with auth middleware hash logic
- use Node crypto SHA-256 against key_hash instead of SQL digest expression
- allow agent-auth comments by using nullable author_id and preserving agent metadata in task log events

Co-authored-by: Holden Omans <holden.omans@gmail.com>
@kalinon kalinon merged commit d10cef2 into main Mar 19, 2026
9 checks passed
@kalinon kalinon deleted the fix/task-route-api-key-auth branch March 19, 2026 03:54
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.

2 participants