Upgrade Babel runtime for optional chaining support - #5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| def get_collection(name: str) -> Any: | ||
| """Return a Mongo collection by name.""" |
There was a problem hiding this comment.
Import typing.Any in database helper
The get_collection annotation references Any but the symbol is never imported. Because annotations are evaluated when the module is imported, loading app.database raises NameError: name 'Any' is not defined, preventing the FastAPI application from starting. Add from typing import Any (or drop the annotation) so the module can be imported.
Useful? React with 👍 / 👎.
| cursor = messages.find(query).sort("created_at", -1).limit(limit) | ||
| history: list[Dict[str, Any]] = [] | ||
| async for item in cursor: | ||
| event_time = item.get("event_time") | ||
| item["id"] = _serialize_id(item.pop("_id")) | ||
| item["created_at"] = item["created_at"].isoformat() | ||
| if event_time: | ||
| item["event_time"] = event_time.isoformat() |
There was a problem hiding this comment.
Guard string event_time values when serialising history
Messages saved from the UI send event_time as a plain ISO string. fetch_history assumes the field is a datetime object and unconditionally calls event_time.isoformat(). When a message with a string timestamp exists, this branch raises AttributeError and the /common/… or /rooms/…/history endpoints fail. Parse event_time to a datetime before storing or skip the .isoformat() call when it is already a string.
Useful? React with 👍 / 👎.
| async def list_subscriptions(user_id: str) -> list[Dict[str, Any]]: | ||
| """Return all subscriptions for user.""" | ||
|
|
||
| collection = get_collection("subscriptions") | ||
| cursor = collection.find({"user_id": user_id}).sort("created_at", -1) | ||
| subscriptions: list[Dict[str, Any]] = [] | ||
| async for item in cursor: | ||
| item["id"] = _serialize_id(item.pop("_id")) | ||
| if item.get("when_start"): | ||
| item["when_start"] = item["when_start"].isoformat() | ||
| if item.get("when_end"): |
There was a problem hiding this comment.
Parse subscription time filters from strings before formatting
During subscription creation the when_start and when_end values are written straight from the payload (UI submits datetime-local strings). Later, list_subscriptions assumes these fields are datetime objects and calls .isoformat() on them. When a user specifies time bounds, this results in AttributeError and the listing/matching code fails. Convert the incoming strings to datetime before persistence or guard against strings when serialising.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68e2dc54ec58832eac05775e82694a53