Skip to content

fix: remove unreachable created_at backfill in update_task_status#212

Open
bsbodden wants to merge 1 commit intomainfrom
bsb/fix-task-created-at-dead-code
Open

fix: remove unreachable created_at backfill in update_task_status#212
bsbodden wants to merge 1 commit intomainfrom
bsb/fix-task-created-at-dead-code

Conversation

@bsbodden
Copy link
Collaborator

@bsbodden bsbodden commented Mar 13, 2026

Summary

  • Remove dead backfill code in update_task_status that checked if task.created_at is None
  • Task.created_at is a non-optional datetime field with default_factory, so model_validate_json rejects null values before the backfill could execute
  • Remove unused UTC import

Changes

  • agent_memory_server/tasks.py: Remove unreachable lines 95-97, remove unused UTC import
  • tests/integration/test_task_created_at_invariant.py: 3 tests documenting the created_at invariant and confirming null values in Redis are treated as corrupt

Test plan

  • All 3 new integration tests pass
  • Full existing test suite passes (710 passed, 0 failures)

Closes #208


Note

Low Risk
Low risk: removes unreachable created_at backfill logic and adds integration coverage; runtime behavior only changes in that update_task_status no longer mutates tasks on the (already-unparseable) corrupt created_at=null case.

Overview
Removes the unreachable created_at backfill in update_task_status (and the now-unused UTC import), relying on the Task model’s non-null created_at invariant rather than attempting to patch invalid data at update time.

Adds an integration regression suite asserting created_at is set on create_task, preserved across status updates, and that tasks with created_at=null stored in Redis are treated as corrupt (i.e., get_task returns None and update_task_status becomes a no-op).

Written by Cursor Bugbot for commit b116912. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings March 13, 2026 23:15
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

@jit-ci
Copy link

jit-ci bot commented Mar 13, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 None backfill in update_task_status (and dropped the now-unused UTC import).
  • Added integration tests asserting created_at is set on create, preserved on updates, and that created_at=null payloads 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.

@bsbodden bsbodden force-pushed the bsb/fix-task-created-at-dead-code branch from bc9101a to f3e16d0 Compare March 13, 2026 23:38
@bsbodden bsbodden self-assigned this Mar 14, 2026
@bsbodden bsbodden added the bug Something isn't working label Mar 14, 2026
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
@bsbodden bsbodden force-pushed the bsb/fix-task-created-at-dead-code branch from f3e16d0 to b116912 Compare March 16, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: remove unreachable created_at backfill in update_task_status

2 participants