Invitation pages return 500 when expires_at is infinity or -infinity
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- authentication, backend, databases
Research direction
Read server/orcaster_server/auth/service/invitation.py and the expiry checks at server/orcaster_server/auth/router.py:222; the issue identifies all three call sites. Add the helper and unit coverage described in the acceptance criteria, then run the invitation tests and check for remaining direct expiry comparisons. Done means both PostgreSQL infinity values produce the specified responses, existing invitation cases pass, and an Unreleased changelog entry is added.
Written by the indexing model from the issue text.
Description
Problem
invitations.expires_at is a timestamptz NOT NULL column with no CHECK (server/orcaster_server/auth/models.py:98), so PostgreSQL accepts 'infinity' and '-infinity'. The database driver decodes them as naive datetimes (datetime.max and datetime.min, no tzinfo). Finite values come back timezone-aware.
The expiry checks compare the value with datetime.now(UTC) in Python:
GET /auth/accept/{token}:server/orcaster_server/auth/router.py:222invitation_state:server/orcaster_server/auth/service/invitation.py:67consume_invitation(used byPOST /auth/accept/{token}/joinandregister/complete):server/orcaster_server/auth/service/invitation.py:84
Comparing a naive and an aware datetime raises TypeError: can't compare offset-naive and offset-aware datetimes. That exception has no handler, so the invite page and both accept routes answer a plain 500.
The application always writes a finite expiry when it creates an invitation. Only a row written by hand (for example 'infinity' meaning "never expires") can hold these values.
Steps to reproduce
- Create an invitation, then run
UPDATE invitations SET expires_at = 'infinity' WHERE id = '<id>'. - Open
GET /auth/accept/{token}. The response is 500. - Same with
'-infinity', and withPOST /auth/accept/{token}/join.
Proposed change
Add one helper, for example is_expired(inv, now), in server/orcaster_server/auth/service/invitation.py. If expires_at.tzinfo is None, treat it as UTC before comparing. Naive datetime.max then never expires and naive datetime.min is always expired, which matches what the two values mean. Use the helper in the three places above.
Evaluating the expiry in SQL is an alternative. Adding a CHECK (isfinite(expires_at)) constraint is not proposed: it needs a migration on an existing table for a value the application never writes.
Acceptance criteria
-
GET /auth/accept/{token}with-infinityanswers like an expired invitation, not 500. -
GET /auth/accept/{token}withinfinityanswers like a live invitation, not 500. -
POST /auth/accept/{token}/joinandregister/completewith-infinityanswer410(expired). Withinfinitythey accept. No 500. - A unit test of the helper covers an aware finite value, naive
datetime.max, naivedatetime.min, andexpires_at == now. - No direct
expires_at <= nowcomparison on invitations remains outside the helper. - No schema change. Existing tests for expired, valid and disabled-workspace invitations still pass.
- CHANGELOG entry under Unreleased.
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AInvirion/orcaster
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
enhancement good first issue P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug client P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
All issues in AInvirion/orcaster
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day