Skip to content

background_tasks: restore_tenant stores "" for the task owner, which leaks between signal tests #861

Closed

Description

@antosubash

Found while moving `background_tasks` to the module layout (#859). Under the new collection order, a signals test ran its prerun handler without a postrun. That left `_task_owner` at `""`, and owner stamping then failed in four later tests. #859 makes that test call `release_tenant(task_id=...)`, the same call the real postrun handler makes.

The underlying fragility is in the source: `restore_tenant` sets the owner to `""` where `None` would fall through to `current_user_id`. A worker that runs a prerun without its matching postrun (crash, revoked task) could therefore stamp the wrong owner on the next task in that thread. Worth checking whether `None` is the intended reset value and adding a regression test.

https://claude.ai/code/session_01FXHA3ZicrtZ4C5QPEgxfgq

Activity

  1. added a commit that references this issue on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions