Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion netbox_branching/models/branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,12 @@ def migrators(self):
migrators = defaultdict(list)
for migration in self.applied_migrations:
app_label, name = migration.split('.')
module = importlib.import_module(f'{app_label}.migrations.{name}')
try:
module = importlib.import_module(f'{app_label}.migrations.{name}')
except ModuleNotFoundError:
logger = logging.getLogger('netbox_branching.branch')
Copy link
Contributor

@bctiemann bctiemann Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the pattern in this file is to instantiate a new logger for every log line, which I guess makes sense since they're all routed differently for different purposes; but I'd think a more common/less chatty pattern would be to declare all the various loggers at the top instead of ad-hoc. Just a note for consideration though, not a reason to block this merge.

Copy link
Contributor Author

@jeremystretch jeremystretch Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case it's okay because we're only invoking the logger in the event a failure occurs, which should be rare. We should probably devise a more robust logging strategy generally, but that's outside the scope of this bug fix.

logger.warning(f"Failed to load module for migration {migration}; skipping.")
continue
for object_type, migrator in getattr(module, 'objectchange_migrators', {}).items():
migrators[object_type].append(migrator)
return migrators
Expand Down