INVITATION_WITHHELD is an empty-string sentinel that any host callback can return by accident

Open
#47 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, python
Domain
backend

Research direction

Start with server/orcaster_server/auth/config.py and server/orcaster_server/auth/router.py to trace the sentinel type and callback behavior. Update the seam contract in server/orcaster_server/workspaces/seam.py, its tests in server/tests/test_workspaces_seam.py, and add router level coverage for empty strings, None, and the sentinel. Run the relevant tests; done means the acceptance criteria pass and an Unreleased changelog entry is added.

Written by the indexing model from the issue text.

Description

enhancement P3 server

Problem

The host callback AuthConfig.describe_invitation can ask the accept page to reveal nothing. It does so with INVITATION_WITHHELD = "" (server/orcaster_server/auth/config.py:39-40), and the router compares it with == (server/orcaster_server/auth/router.py:228). The callback type is still Awaitable[str | None] (config.py:79).

So an empty string means "withhold" only by convention. return "" type-checks, and a reader cannot tell the intent. The contract says None means "nothing to describe, fall back to the label". If a host builds the description from parts and both are empty, for example f"{prefix}{name}", the callback returns "" and the page silently hides the target line, the label and the account note, with no log line.

Today the only host callback (server/orcaster_server/workspaces/seam.py:38-73) never returns "" by accident, so this is a latent risk, not a live bug.

Tests: the seam tests compare with == and assert INVITATION_WITHHELD == "" (server/tests/test_workspaces_seam.py:295, :313-314). No router-level test passes a stub callback that returns "".

Proposed change

Make the sentinel an object that no string can equal, and widen the callback type so the type checker sees it.

  • Define a small class (for example _Withheld) and INVITATION_WITHHELD: Final = _Withheld() in config.py.
  • Type the callback as Awaitable[str | _Withheld | None].
  • Compare with is in the router. An empty string then falls back to the stored label like any other falsy description.

Alternative: return a small result type (for example text plus a withheld flag). More explicit, but it changes the callback contract for every host.

Acceptance criteria

  • INVITATION_WITHHELD is not equal to any str, including "", and the router compares by identity or type.
  • The type of AuthConfig.describe_invitation names the sentinel type.
  • A router-level test with a stub callback: "" falls back to the stored label; None falls back to the label; the sentinel withholds (neutral line, no label, no description).
  • The seam test asserts identity with the sentinel for a disabled workspace and a string for an enabled one; the old == "" assertion is removed.
  • The comment in config.py and the docstring in seam.py describe the new contract.
  • Behavior of the built-in callback and existing page tests for expired and disabled workspaces is unchanged; existing deployments keep working without config changes.
  • CHANGELOG entry under Unreleased.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.