aminghadersohi commented on code in PR #38977:
URL: https://github.com/apache/superset/pull/38977#discussion_r3016465987


##########
superset/mcp_service/dataset/schemas.py:
##########
@@ -307,6 +308,13 @@ def _parse_json_field(obj: Any, field_name: str) -> 
Dict[str, Any] | None:
     return value
 
 
+def _humanize_timestamp(dt: datetime | None) -> str | None:
+    """Convert a datetime to a humanized string like '2 hours ago'."""
+    if dt is None:
+        return None
+    return humanize.naturaltime(datetime.now() - dt)

Review Comment:
   Actually, I've reverted this back to `datetime.now()` (naive). Superset 
stores naive datetimes in the database, so using `datetime.now(timezone.utc)` 
causes `TypeError: can't subtract offset-naive and offset-aware datetimes`. The 
original `_format_time_humanized()` in `AuditMixinNullable` also uses naive 
`datetime.now()` for this reason.



##########
superset/mcp_service/chart/schemas.py:
##########
@@ -271,6 +272,13 @@ def validate_identifier_or_form_data_key(self) -> 
"GetChartInfoRequest":
         return self
 
 
+def _humanize_timestamp(dt: datetime | None) -> str | None:
+    """Convert a datetime to a humanized string like '2 hours ago'."""
+    if dt is None:
+        return None
+    return humanize.naturaltime(datetime.now() - dt)

Review Comment:
   Reverted to naive `datetime.now()` — Superset DB stores naive timestamps, so 
timezone-aware subtraction fails at runtime. Caught this during staging eval 
testing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to