Skip to content

litestar: SQLSpecPlugin.get_config() unusable before app registration #701

Description

@cofin

Description

SQLSpecPlugin.get_config(name) raises ImproperConfigurationError ("SQLSpec plugin has not been registered with a Litestar application") for both type-based and string-key lookups until on_app_init has run.

The plugin already holds its SQLSpec registry at construction, and that registry knows every registered config, so type/bind-key resolution could be answered without any app-registration state. The registered-app requirement only seems necessary for the DI-key lookups (db_session, db_connection, ...) that are derived during on_app_init.

Use case

Composition roots that build app-scoped adapters/services from the plugin before (or outside) Litestar app construction — e.g. background workers and CLI entry points that share the same wiring. Today the only pre-registration paths are walking plugin.config manually or reaching into the private plugin._sqlspec.

Proposal

  • Let get_config(<config type>) and get_config(<bind_key>) resolve from the wrapped registry regardless of registration state, keeping the registered-app requirement only for DI-key string lookups.
  • Optionally expose the wrapped registry as a public property (e.g. plugin.sqlspec) so integrators don't need _sqlspec.

Version

sqlspec 0.58.x (litestar extension)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions