DailyRESTHelper.create_room creates rooms with stale expirations
chrisnolet opened this issue · comments
When creating multiple rooms with successive calls to create_room
, the default exp
is only calculated on the first call. Subsequent calls to create_room
get the same (stale) expiry.
This eventually results in the error:
Exception: Unable to create room: {"error":"invalid-request-error","info":"exp was '...', which is in the past rather than in the future"}
Example repro:
room_params_1 = DailyRoomParams()
time.sleep(1)
room_params_2 = DailyRoomParams()
print("Expiration 1:", room_params_1.properties.exp) // Prints 1723039021.722903
print("Expiration 2:", room_params_2.properties.exp) // Prints 1723039021.722903
Fix:
Using a Field
for DailyRoomParams.properties
in daily_rest.py
appears to work:
class DailyRoomParams(BaseModel):
name: Optional[str] = None
privacy: Literal['private', 'public'] = "public"
- properties: DailyRoomProperties = DailyRoomProperties()
+ properties: DailyRoomProperties = Field(default_factory=DailyRoomProperties)
Workaround:
You can call create_room
with a new instance of DailyRoomProperties
at the call site:
room = daily_rest_helper.create_room(DailyRoomParams(properties=DailyRoomProperties()))
Along the same lines, you can also provide an explicit expiration with:
expiration = time.time() + 5 * 60
room = daily_rest_helper.create_room(DailyRoomParams(properties=DailyRoomProperties(exp=expiration)))
Oh. Good catch! I fixed the exp
field in a previous commit ccd6af7, but not the properties
one!
Feel free to submit a PR next time and I'd be happy to review and merge it. Thank you! 🙇