[PR #385] [MERGED] Normalize today-workflow task dependencies to arrays and backfill legacy string values #687

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

📋 Pull Request Information

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

Base: mainHead: codex/update-task-creation-dependencies-handling


📝 Commits (1)

  • c3f478a Normalize today workflow task dependencies as arrays

📊 Changes

3 files changed (+71 additions, -5 deletions)

View changed files

📝 backend/api/today_workflow.py (+15 -2)
📝 backend/services/today_workflow_service.py (+20 -1)
📝 frontend/src/stores/workflowStore.ts (+36 -2)

📄 Description

Motivation

  • Existing task creation persisted dependencies as a JSON-encoded string which is incompatible with consumers expecting string[], so new tasks should store dependencies as native arrays.
  • There may be legacy rows where dependencies are still string values, so reads must be backward-compatible and migrate those rows to the new array format.

Description

  • Added coerce_dependencies(value: Any) -> List[str] in backend/services/today_workflow_service.py to normalize inputs that may be list, JSON strings, or plain strings into List[str] and used it when creating DailyWorkflowTask so new rows store arrays instead of JSON-encoded strings.
  • Updated backend/api/today_workflow.py to import coerce_dependencies, to use coerce_dependencies(t.dependencies) when serializing API responses, and to run _normalize_legacy_dependencies (executed off the request thread) which parses string-valued legacy rows into arrays and persists the normalized values back to the DB.
  • Hardened the frontend consumer at frontend/src/stores/workflowStore.ts by adding normalizeDependencies and normalizeServerWorkflow so any server payload (legacy string or array) is coerced to string[] before being stored in client state.
  • These changes keep the DB column as JSON (DailyWorkflowTask.dependencies) while ensuring new writes are arrays and existing string rows are migrated on read.

Testing

  • Successfully ran python -m py_compile backend/services/today_workflow_service.py backend/api/today_workflow.py which passed with no syntax errors.
  • Attempted frontend validation: npm run -s typecheck returned a non-zero exit in this environment and CI=1 npm run build failed because react-scripts is not installed in the environment, so full frontend build/typecheck could not be completed here.

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/385 **Author:** [@AJaySi](https://github.com/AJaySi) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/7/2026 **Merged by:** [@AJaySi](https://github.com/AJaySi) **Base:** `main` ← **Head:** `codex/update-task-creation-dependencies-handling` --- ### 📝 Commits (1) - [`c3f478a`](https://github.com/AJaySi/ALwrity/commit/c3f478a763b4b1a5609382228c081dcb08812a9a) Normalize today workflow task dependencies as arrays ### 📊 Changes **3 files changed** (+71 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `backend/api/today_workflow.py` (+15 -2) 📝 `backend/services/today_workflow_service.py` (+20 -1) 📝 `frontend/src/stores/workflowStore.ts` (+36 -2) </details> ### 📄 Description ### Motivation - Existing task creation persisted `dependencies` as a JSON-encoded string which is incompatible with consumers expecting `string[]`, so new tasks should store `dependencies` as native arrays. - There may be legacy rows where `dependencies` are still string values, so reads must be backward-compatible and migrate those rows to the new array format. ### Description - Added `coerce_dependencies(value: Any) -> List[str]` in `backend/services/today_workflow_service.py` to normalize inputs that may be `list`, JSON strings, or plain strings into `List[str]` and used it when creating `DailyWorkflowTask` so new rows store arrays instead of JSON-encoded strings. - Updated `backend/api/today_workflow.py` to import `coerce_dependencies`, to use `coerce_dependencies(t.dependencies)` when serializing API responses, and to run `_normalize_legacy_dependencies` (executed off the request thread) which parses string-valued legacy rows into arrays and persists the normalized values back to the DB. - Hardened the frontend consumer at `frontend/src/stores/workflowStore.ts` by adding `normalizeDependencies` and `normalizeServerWorkflow` so any server payload (legacy string or array) is coerced to `string[]` before being stored in client state. - These changes keep the DB column as JSON (`DailyWorkflowTask.dependencies`) while ensuring new writes are arrays and existing string rows are migrated on read. ### Testing - Successfully ran `python -m py_compile backend/services/today_workflow_service.py backend/api/today_workflow.py` which passed with no syntax errors. - Attempted frontend validation: `npm run -s typecheck` returned a non-zero exit in this environment and `CI=1 npm run build` failed because `react-scripts` is not installed in the environment, so full frontend build/typecheck could not be completed here. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69aaf76bdc5c8328a3ef942800142bb9) --- <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:00 +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#687
No description provided.