Skip to content

[ci:fix] Fixed changelog bot commitizen circular import #669#671

Merged
nemesifier merged 2 commits into
masterfrom
issues/669-changelogbot-commitizen-import-error
May 9, 2026
Merged

[ci:fix] Fixed changelog bot commitizen circular import #669#671
nemesifier merged 2 commits into
masterfrom
issues/669-changelogbot-commitizen-import-error

Conversation

@nemesifier
Copy link
Copy Markdown
Member

Force commitizen plugin discovery before importing the OpenWispCommitizen plugin, otherwise the discovery re-imports our module while it is still mid-initialization causing issue #669.

Closes #669.

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • N/A I have updated the documentation.

@nemesifier nemesifier self-assigned this May 9, 2026
@nemesifier nemesifier added the bug label May 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1f627795-503a-469a-a15e-2cc9f3639a68

📥 Commits

Reviewing files that changed from the base of the PR and between 0e66d19 and d2c5874.

📒 Files selected for processing (2)
  • .github/actions/bot-changelog-generator/generate_changelog.py
  • .github/actions/bot-changelog-generator/test_generate_changelog.py
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Kilo Code Review
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-03-05T09:59:15.097Z
Learnt from: pushpitkamboj
Repo: openwisp/openwisp-utils PR: 584
File: .github/actions/bot-changelog-generator/generate_changelog.py:356-364
Timestamp: 2026-03-05T09:59:15.097Z
Learning: In generate_changelog.py, reviews should confirm that validate_changelog_output acts as an output safety filter: it should require the produced changelog text to begin with a valid tag ([feature], [fix], or [change]) and to include a correctly formed PR reference pattern. It should NOT require that the referenced PR number or URL exactly match the current PR. For review, check: (1) the first non-space token matches one of the allowed tags, (2) the PR reference pattern is present and well-formed (e.g., contains a recognizable PR identifier or URL), and (3) there are no additional hard-coded cross-checks that would make it overly strict. This pattern should apply to this file specifically and guide future changes to similar output-filter functions without assuming cross-repo constraints.

Applied to files:

  • .github/actions/bot-changelog-generator/generate_changelog.py
🔇 Additional comments (3)
.github/actions/bot-changelog-generator/generate_changelog.py (1)

401-413: Import-order guard is a solid fix for the circular import path.

The lazy load sequence here is clear and appropriately constrained to the problematic bootstrap point.

.github/actions/bot-changelog-generator/test_generate_changelog.py (2)

23-23: Test import wiring looks correct.

Adding get_openwisp_commitizen to the import list is aligned with the new regression coverage.


528-571: Regression test setup/teardown is well isolated.

The fresh-import simulation and module-cache restoration are implemented cleanly and target the original failure mode well.


📝 Walkthrough

Walkthrough

The PR fixes a circular import issue in the changelog bot by modifying get_openwisp_commitizen() to force an explicit import of commitizen.cz before loading OpenWispCommitizen. This ensures Commitizen's plugin auto-discovery completes before the OpenWISP plugin is imported, preventing the registry from trying to re-import the same module. A regression test validates the fix by clearing module caches and confirming the plugin loads with expected attributes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • openwisp/openwisp-utils#657: Both PRs modify the get_openwisp_commitizen() helper function and address OpenWispCommitizen plugin-loading behavior.
  • openwisp/openwisp-utils#590: Related through changes to the OpenWispCommitizen plugin symbol in openwisp_utils.releaser.commitizen.

Suggested labels

github_actions, helper-bots

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required format [type] with 'ci:fix' as the type and includes a descriptive message addressing the circular import issue.
Description check ✅ Passed The description includes issue reference, clear explanation of the problem and solution, and a completed checklist following the template structure.
Linked Issues check ✅ Passed The code changes directly address issue #669 by forcing commitizen plugin discovery before importing OpenWispCommitizen, preventing circular imports during initialization.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving the circular import issue in the changelog bot's commitizen integration, with no unrelated modifications.
Bug Fixes ✅ Passed Fixes circular import root cause. Regression test clears sys.modules and verifies plugin loads. Test is deterministic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issues/669-changelogbot-commitizen-import-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented May 9, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR effectively fixes the circular import issue (#669) in the changelog bot. The fix is minimal, well-documented, and properly tested.

What was fixed:

  • Added explicit import commitizen.cz before importing OpenWispCommitizen to ensure plugin auto-discovery completes first
  • Clear docstring explains the import ordering requirement and references issue [ci:fix] Prevent circular import in changelog bot Commitizen validation #669
  • Comprehensive regression test (TestGetOpenwispCommitizen) with proper module cache isolation via setUp/tearDown

Files Reviewed (2 files):

  • .github/actions/bot-changelog-generator/generate_changelog.py - Added import ordering fix with explanatory docstring
  • .github/actions/bot-changelog-generator/test_generate_changelog.py - Added regression test for the circular import fix

Reviewed by kimi-k2.5-0127 · 122,105 tokens

@coderabbitai coderabbitai Bot added github_actions Pull requests that update GitHub Actions code helper-bots Helper bots, release management automation labels May 9, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented May 9, 2026

Coverage Status

coverage: 97.513%. remained the same — issues/669-changelogbot-commitizen-import-error into master

@nemesifier nemesifier merged commit 8aa5674 into master May 9, 2026
19 checks passed
@nemesifier nemesifier deleted the issues/669-changelogbot-commitizen-import-error branch May 9, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug github_actions Pull requests that update GitHub Actions code helper-bots Helper bots, release management automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ci:fix] Prevent circular import in changelog bot Commitizen validation

2 participants