Skip to content

fix: mutable global state in _CUSTOM_CHECKS is not thread-safe #93

@rororowyourboat

Description

@rororowyourboat

Problem

packages/gds-framework/gds/helpers.py:170 — The _CUSTOM_CHECKS module-level list is mutated by the @gds_check decorator at import time. No locking or thread-safety mechanism exists.

Same concern applies to GDSSpec (spec.py) — a mutable registry with no concurrent access guards.

Impact

  • Parallel test runners could register checks multiple times
  • Multi-threaded applications building specs concurrently could corrupt state
  • Not a problem today (single-threaded usage), but a latent issue

Options

  1. Document that _CUSTOM_CHECKS and GDSSpec are not thread-safe (cheapest)
  2. Add threading.Lock guards to mutation points
  3. Use contextvars for per-context isolation

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions