updated apps
This commit is contained in:
@@ -13,7 +13,9 @@ from __future__ import annotations
|
||||
from typing import Any
|
||||
|
||||
from ..const import (
|
||||
MAX_COST,
|
||||
MAX_DATE_LENGTH,
|
||||
MAX_DURATION_MINUTES,
|
||||
MAX_ENTITY_SLUG_LENGTH,
|
||||
MAX_ICON_LENGTH,
|
||||
MAX_ID_LENGTH,
|
||||
@@ -43,6 +45,11 @@ _TASK_STR_LIMITS: dict[str, int] = {
|
||||
"responsible_user_id": MAX_META_LENGTH,
|
||||
"entity_slug": MAX_ENTITY_SLUG_LENGTH,
|
||||
"created_at": MAX_DATE_LENGTH,
|
||||
# Lifecycle metadata that now round-trips through JSON import (audit
|
||||
# 2026-07-11): an ISO timestamp + a short reason code. Length-capped so a
|
||||
# crafted backup can't smuggle oversized strings past the importer.
|
||||
"archived_at": MAX_META_LENGTH,
|
||||
"archived_reason": MAX_META_LENGTH,
|
||||
"schedule_time": MAX_SCHEDULE_TIME_LENGTH,
|
||||
"priority": MAX_TYPE_LENGTH,
|
||||
"reading_unit": 32,
|
||||
@@ -60,6 +67,12 @@ _OBJECT_STR_LIMITS: dict[str, int] = {
|
||||
"notes": MAX_TEXT_LENGTH, # v1.4.10 #46
|
||||
"ha_device_id": MAX_ID_LENGTH, # 2.19: link to an existing HA device
|
||||
"parent_entry_id": MAX_ID_LENGTH, # 2.19: parent object (via_device)
|
||||
# 2.20 pause + replace lineage — capped so an imported backup can't smuggle
|
||||
# oversized strings into these (import copies them verbatim).
|
||||
"paused_at": MAX_META_LENGTH, # ISO timestamp marker (presence = paused)
|
||||
"paused_until": MAX_DATE_LENGTH, # auto-resume date
|
||||
"predecessor_entry_id": MAX_ID_LENGTH,
|
||||
"replaced_by_entry_id": MAX_ID_LENGTH,
|
||||
}
|
||||
|
||||
_GROUP_STR_LIMITS: dict[str, int] = {
|
||||
@@ -291,15 +304,19 @@ def cap_quick_complete_defaults_field(task_data: dict[str, Any]) -> None:
|
||||
cleaned["notes"] = notes[:MAX_TEXT_LENGTH]
|
||||
|
||||
cost = defaults.get("cost")
|
||||
if isinstance(cost, (int, float)) and 0 <= cost <= 1_000_000:
|
||||
if isinstance(cost, (int, float)) and 0 <= cost <= MAX_COST:
|
||||
cleaned["cost"] = float(cost)
|
||||
|
||||
duration = defaults.get("duration")
|
||||
if isinstance(duration, int) and 0 <= duration <= 525_600:
|
||||
if isinstance(duration, int) and 0 <= duration <= MAX_DURATION_MINUTES:
|
||||
cleaned["duration"] = duration
|
||||
|
||||
from ..const import MaintenanceFeedback
|
||||
|
||||
feedback = defaults.get("feedback")
|
||||
if feedback in ("needed", "not_needed"):
|
||||
# Use the enum (needed / not_needed / not_sure) — a bare ("needed",
|
||||
# "not_needed") literal silently dropped a valid not_sure feedback.
|
||||
if feedback in tuple(MaintenanceFeedback):
|
||||
cleaned["feedback"] = feedback
|
||||
|
||||
if cleaned:
|
||||
|
||||
Reference in New Issue
Block a user