Skip to content

rx.Model with table=True on a bare install raises bare TypeError instead of "pip install reflex[db]" guidance #6973

Closed

Description

@masenf

Describe the bug

On an install without the db extra (no sqlmodel/sqlalchemy), declaring a table model — the standard form from the docs — dies with a bare TypeError at class-definition time, with no hint that reflex[db] is needed.

The helpful ImportError ("Database is not available. Please install ... reflex[db]") only triggers on instantiation via _ClassThatErrorsOnInit.__init__, but users hit __init_subclass__ first because table=True is passed as a class keyword.

To Reproduce

uv venv /tmp/v && uv pip install --python /tmp/v/bin/python --prerelease=allow 'reflex==0.9.9a1'
/tmp/v/bin/python -c "
import reflex as rx

class Item(rx.Model, table=True):
    name: str
"

Observed behavior

TypeError: Item.__init_subclass__() takes no keyword arguments

Expected behavior

An error pointing at the fix, e.g. Database is not available. Please run pip install "reflex[db]" — the same guidance the instantiation path already gives.

Root cause (from source)

reflex/model.py: when sqlmodel/sqlalchemy are absent, Model is aliased to _ClassThatErrorsOnInit, which overrides only __init__. A subclass declaration passing class keywords (table=True) routes them to object.__init_subclass__, which accepts no kwargs and raises the bare TypeError before the guided ImportError path (_print_db_not_available) is ever reached. Adding an __init_subclass__ override to _ClassThatErrorsOnInit that raises the guided error would cover it. (Plain subclassing without kwargs is even silently accepted and only errors later on use.)

Specifics (please complete the following information):

  • Python Version: 3.11
  • Reflex Version: 0.9.9a1
  • OS: linux

Additional context

  • Severity: low. Not a regression — 0.9.8 behaves the same — but the pydantic-optional work makes minimal installs more common, so more users will hit it.
  • Found during 0.9.9a1 pre-release testing; probe output is on branch claude/reflex-prerelease-testing-t0sd90 under prerelease-testing/2026-08-27-v0.9.9a1/pydantic_optional/.

Activity

  1. added
    bug
    on Aug 28, 2026
  2. linear-code commented on Aug 28, 2026

    @linear-code
  3. added a commit that references this issue on Sep 11, 2026
    e34899f
  4. added
    release-train
    on Nov 11, 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

    bugrelease-train

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions