Skip to content

AttributeError in _create_table_model when table_config is None #48

@moizahmed-de

Description

@moizahmed-de

Description: _create_table_model crashes when tables_config returns None

In _create_table_model in model.py, tables_config.get(table_name, {}) can return None if a table is explicitly configured with a None value in the config dict (e.g., from a YAML config file where a key exists but has no value).

When this happens, the following line raises an AttributeError because None has no .get() method:

if table_config.get("reuse", True):  # AttributeError if table_config is None

https://github.com/cre-dev/xml2db/blob/0.12.5/src/xml2db/model.py#L197

Steps to Reproduce

Provide a model config (e.g., via YAML) where a table key exists but has no value:

tables:
  SomeTable:    # this results in None, not {}
from xml2db import DataModel

model = DataModel(
    xsd_file="path/to/file.xsd",
    model_config={"tables": {"SomeTable": None}},
)

This raises:

AttributeError: 'NoneType' object has no attribute 'get'

Suggested Fix

Add a None-safe fallback:

if (table_config or {}).get("reuse", True):

This ensures that if table_config resolves to None, it falls back to an empty dict before calling .get().

Environment

  • xml2db version: 0.12.5
  • Python version: 3.14.2
  • xmlschema version: 4.3.1
  • OS: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions