fix: remove unreachable created_at backfill in update_task_status#212
Open
fix: remove unreachable created_at backfill in update_task_status#212
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Contributor
There was a problem hiding this comment.
Pull request overview
Removes unreachable created_at backfill logic from task status updates and adds regression coverage to enforce the invariant that Task.created_at is always non-null (and that created_at: null data in Redis is treated as corrupt/unrecoverable).
Changes:
- Removed dead
created_at is Nonebackfill inupdate_task_status(and dropped the now-unusedUTCimport). - Added integration tests asserting
created_atis set on create, preserved on updates, and thatcreated_at=nullpayloads in Redis cannot be parsed/updated.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
agent_memory_server/tasks.py |
Deletes unreachable created_at backfill and removes unused UTC import while preserving datetime for type hints. |
tests/integration/test_task_created_at_invariant.py |
Adds regression tests that document/enforce the created_at non-null invariant and corrupt-data handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bc9101a to
f3e16d0
Compare
The backfill code in update_task_status (lines 95-97) was unreachable because Task.created_at is a non-optional datetime field — Pydantic's model_validate_json rejects null values before the backfill could run. Remove the dead code and add tests documenting the created_at invariant. Also remove the unused UTC import. Closes #208
f3e16d0 to
b116912
Compare
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.
Summary
update_task_statusthat checkedif task.created_at is NoneTask.created_atis a non-optionaldatetimefield withdefault_factory, somodel_validate_jsonrejects null values before the backfill could executeUTCimportChanges
agent_memory_server/tasks.py: Remove unreachable lines 95-97, remove unusedUTCimporttests/integration/test_task_created_at_invariant.py: 3 tests documenting thecreated_atinvariant and confirming null values in Redis are treated as corruptTest plan
Closes #208
Note
Low Risk
Low risk: removes unreachable
created_atbackfill logic and adds integration coverage; runtime behavior only changes in thatupdate_task_statusno longer mutates tasks on the (already-unparseable) corruptcreated_at=nullcase.Overview
Removes the unreachable
created_atbackfill inupdate_task_status(and the now-unusedUTCimport), relying on theTaskmodel’s non-nullcreated_atinvariant rather than attempting to patch invalid data at update time.Adds an integration regression suite asserting
created_atis set oncreate_task, preserved across status updates, and that tasks withcreated_at=nullstored in Redis are treated as corrupt (i.e.,get_taskreturnsNoneandupdate_task_statusbecomes a no-op).Written by Cursor Bugbot for commit b116912. This will update automatically on new commits. Configure here.