fix(api): bound message writes across REST and MCP - #445
Conversation
Cap writes at 100 messages, 64 KiB UTF-8 per content string, and 1 MiB combined content. Insert valid batches transactionally in D1-safe chunks and cover boundary rejection, counters, ordering, bind limits, and rollback. Refs #435 Co-Authored-By: Duyet Le <me@duyet.net> Co-Authored-By: duyetbot <bot@duyet.net>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideThis PR enforces shared 100-message, 64 KiB-per-string, and 1 MiB-combined UTF-8 limits across REST, trace, and MCP writes, then routes all message persistence through transactional five-row D1 batches to stay under bind limits; documentation and comprehensive boundary/atomicity regression tests accompany the implementation. Sequence diagram for transactional message insertionsequenceDiagram
participant API as REST, Trace, or MCP handler
participant Service as Conversation or message service
participant Insert as insertMessageRows
participant D1 as D1 database
API->>Service: Validate bounded message input
Service->>Insert: insertMessageRows(rows)
Insert->>D1: db.batch(5-row insert statements)
D1-->>Insert: Commit all chunks or roll back
Insert-->>Service: Insertion result
Service-->>API: Success or database error
Flow diagram for bounded message writesflowchart LR
Write["REST create or append, trace ingestion, or MCP store_conversation"] --> Schema["Shared validation"]
Schema --> Limits["100 messages; 64 KiB per content; 1 MiB combined UTF-8"]
Limits -->|valid| Rows["Build message rows"]
Limits -->|invalid| Error["REST 400 BAD_REQUEST or MCP INVALID_PARAMS"]
Rows --> Batch["insertMessageRows"]
Batch --> D1["Transactional D1 batches of 5 rows"]
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary
Verification
Scope
Co-Authored-By: Duyet Le me@duyet.net
Co-Authored-By: duyetbot bot@duyet.net
🤖 Generated with Claude Code
Summary by Sourcery
Bound message writes across all supported API ingestion paths and make large valid batches transactional within D1 limits.
Bug Fixes:
Enhancements:
Documentation:
Tests: