Repository navigation
Conversation
…n appending
POST /tasks/{id}/notes/append only validated the appended chunk, so
repeated appends could grow a note past the limit PUT enforces.
The limit is now checked in the same UPDATE that appends
(WHERE length(content) + :len <= :max), so the check stays atomic with
the append. When no row is updated, an existing note means overflow
(NotesTooLargeError -> 422, note untouched); a missing note is created.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
POST /api/v1/tasks/{task_id}/notes/append(#1294) only validated the appended chunk againstMAX_NOTES_LENGTH, whilePUT .../notescaps the whole body. Repeated appends could therefore grow a note past the limit. This PR makes the append respect the limit on the resulting note size, atomically.Related Issue
Closes #1295
Type of Change
Changes Made
SqliteNotesRepository.append_notes/NotesRepository.append_notestake an optionalmax_length. The check is part of the append's ownUPDATE(WHERE length(content) + :len <= :max), so it stays atomic and does not bring back the read-then-write race fixed in feat(server/client/mcp): atomic append_task_note to prevent lost note-log updates #1094. If no row was updated, an existing note means overflow (NotesTooLargeError, note untouched); a missing note is created as before (rejected if the chunk alone exceeds the limit). The concurrent-createIntegrityErrorretry uses the same guarded statement.NotesController.append_notesforwardsmax_length; the router passes the existingMAX_NOTES_LENGTH(the constant is not duplicated in core).NotesTooLargeError(aTaskValidationError) mapped to 422 inerror_handlers.py, the same statusPUTreturns for an oversized body.updated_atunchanged, character vs byte length, missing note), controller, and router with the in-memory test repository (two 600k appends -> 200 then 422; exact fit at 1,000,000 -> 200).Testing
Test Environment
Tests Performed
pytest tests/for taskdog-core and taskdog-server; taskdog-ui, client and mcp are untouched and were not run)Code Quality Checklist
make lint)make typecheck)make format)Documentation
Package Affected
Breaking Changes
append_notesgains an optionalmax_lengthparameter (defaultNone, no limit), so existing callers are unaffected.Screenshots/Output
Test results: taskdog-core 1210 passed, taskdog-server 378 passed;
make lint format typecheckandpre-commit run --files <changed>pass.Checklist
Additional Notes
The status is 422 to match
PUTand the existing oversized-chunk response on this endpoint.Known limitation, not new in this PR: SQLite
length()stops at the first U+0000, so a note containing a NUL character is under-counted by the guard. Rejecting NUL in notes requests could be a follow-up if you want it.This PR was prepared with AI assistance (Claude Code). I have reviewed the change and the test results.
For Maintainers: