[PR #396] [MERGED] Validate plan.date before yesterday indexing and narrow exception handling #701

Closed
opened 2026-03-13 21:04:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AJaySi/ALwrity/pull/396
Author: @AJaySi
Created: 3/6/2026
Status: Merged
Merged: 3/8/2026
Merged by: @AJaySi

Base: mainHead: codex/validate-plan.date-format-and-log-warnings


📝 Commits (1)

  • e694e61 Validate plan date before yesterday workflow indexing

📊 Changes

1 file changed (+40 additions, -20 deletions)

View changed files

📝 backend/api/today_workflow.py (+40 -20)

📄 Description

Motivation

  • Ensure plan.date is a valid ISO date before computing the previous day to avoid crashes or silent failures when indexing yesterday's tasks.
  • Provide actionable logs when skipping yesterday indexing so operators can diagnose malformed dates or DB issues.
  • Avoid broad except Exception: pass patterns and handle parse and DB errors explicitly for safer failure modes.

Description

  • Added from sqlalchemy.exc import SQLAlchemyError and validate plan.date using date.fromisoformat(plan.date) before computing y_str in backend/api/today_workflow.py.
  • When parsing fails, log a warning with plan.id, user_id, plan.date, and an explicit skip reason instead of proceeding or swallowing the error.
  • Wrap the DB fetch for yesterday's tasks with except SQLAlchemyError as db_error and log a clear warning including plan_id, user_id, plan_date, yesterday_date, and error details; keep indexing behavior unchanged on success.

Testing

  • Ran python -m py_compile backend/api/today_workflow.py which completed successfully.

Codex Task


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AJaySi/ALwrity/pull/396 **Author:** [@AJaySi](https://github.com/AJaySi) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/8/2026 **Merged by:** [@AJaySi](https://github.com/AJaySi) **Base:** `main` ← **Head:** `codex/validate-plan.date-format-and-log-warnings` --- ### 📝 Commits (1) - [`e694e61`](https://github.com/AJaySi/ALwrity/commit/e694e6172fd6c2667ae8620a70305907d262c8de) Validate plan date before yesterday workflow indexing ### 📊 Changes **1 file changed** (+40 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `backend/api/today_workflow.py` (+40 -20) </details> ### 📄 Description ### Motivation - Ensure `plan.date` is a valid ISO date before computing the previous day to avoid crashes or silent failures when indexing yesterday's tasks. - Provide actionable logs when skipping yesterday indexing so operators can diagnose malformed dates or DB issues. - Avoid broad `except Exception: pass` patterns and handle parse and DB errors explicitly for safer failure modes. ### Description - Added `from sqlalchemy.exc import SQLAlchemyError` and validate `plan.date` using `date.fromisoformat(plan.date)` before computing `y_str` in `backend/api/today_workflow.py`. - When parsing fails, log a warning with `plan.id`, `user_id`, `plan.date`, and an explicit skip reason instead of proceeding or swallowing the error. - Wrap the DB fetch for yesterday's tasks with `except SQLAlchemyError as db_error` and log a clear warning including `plan_id`, `user_id`, `plan_date`, `yesterday_date`, and error details; keep indexing behavior unchanged on success. ### Testing - Ran `python -m py_compile backend/api/today_workflow.py` which completed successfully. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69aafa6b4d18832896be47daa43532a9) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-13 21:04:32 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ALwrity#701
No description provided.