Skip to content

Handle malformed message send payloads#80

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
phucnguyen1707:fix-message-send-validation
Jun 11, 2026
Merged

Handle malformed message send payloads#80
ralyodio merged 1 commit into
profullstack:masterfrom
phucnguyen1707:fix-message-send-validation

Conversation

@phucnguyen1707

Copy link
Copy Markdown
Contributor

Summary

POST /api/messages/send returned 500 for client-side payload errors. This patch validates the request body before touching the database:

  • malformed JSON now returns 400
  • non-object bodies, array/empty encryptedContents, and non-string encrypted content values now return 400
  • invalid encrypted content no longer inserts and then deletes a message row before failing

I also added regression tests for the invalid payload cases.

Verification

  • pnpm vitest run src/app/api/messages/send/route.test.js
  • git diff --check

Note: local eslint/prettier commands are currently blocked by existing missing dev dependencies in the repo config (globals, prettier-plugin-svelte).

@ralyodio ralyodio merged commit c6d65ca into profullstack:master Jun 11, 2026
8 checks passed
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