Skip to content

ModuleNotFoundError exception raised when attempting to merge a branch after upgrading to NetBox v4.4 #371

@jeremystretch

Description

@jeremystretch

Plugin Version

v0.7.2

NetBox Version

v4.4.7

Python Version

3.12

Steps to Reproduce

  1. Start with NetBox v4.3.7 and netbox-branching v0.6.2
  2. Create a branch
  3. Upgrade to NetBox v4.4.7 and netbox-branching v0.7.2
  4. Create a site in the branch (bug is not specific to the type of change being made)
  5. Attempt to merge the branch

Expected Behavior

The branch should merge successfully.

Observed Behavior

The merge job fails with the following error message:

Error: ModuleNotFoundError("No module named 'thumbnail'")

After some investigation, I've discovered the root cause lies inside the migrators() method on the Branch model:

migrators = defaultdict(list)
for migration in self.applied_migrations:
app_label, name = migration.split('.')
module = importlib.import_module(f'{app_label}.migrations.{name}')
for object_type, migrator in getattr(module, 'objectchange_migrators', {}).items():
migrators[object_type].append(migrator)
return migrators

Line 317 attempts to resolve the app to which a migration belongs. This fails on the thumbnail.0001_initial migration, because sorl-thumbnail installs as sorl.thumbnail but its migration is prefixed only with thumbnail.

As this method merely looks for object-specific migrators, it's probably safe to simply ignore any import failures.

Metadata

Metadata

Assignees

Labels

app: branchingseverity: highCompletely breaks certain functions, or substantially degrades performance application-widestatus: acceptedtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions