[feature] Introduced standalone certificate templates and device bindings
Checklist
- [x] I have read the OpenWISP Contributing Guidelines.
- [x] I have manually tested the changes proposed in this pull request.
- [x] I have written new test cases for new code and/or updated existing tests for changes to existing code.
- [x] I have updated the documentation.
Reference to Existing Issue
Closes #1356 Closes #1377 Closes #1357 Closes #1361 Closes #1358 Closes #1360 Closes #1359
Description of Changes
This PR establishes the database architecture, UI, API and lifecycle for standalone X.509 certificate templates.
Manual test plan
Setup
- Go to
PKI->Certification Authoritiesand create two CAs:CA-1andCA-2. - Go to
PKI->Certificatesand create two certificates to act as blueprints: Blueprint-1(Must useCA-1)Blueprint-2(Must useCA-2)- Go to
Devicesand create a device (test-device).
Template Creation and Validation
Configuration->Templatesand clickADD TEMPLATE.- Set Type to
Certificate.- Leave CA blank and try to save.
- Expected Result: Validation error stating a CA is required.
- Set CA to
CA-1.- Set Blueprint to
Blueprint-2(which belongs toCA-2). Try to save. - When opening drop-down for blueprint you'll only see unassigned and unrevoked certificates.
- Expected Result: Validation error stating the Blueprint must match the selected CA.
- Set Blueprint to
- Change Blueprint to
Blueprint-1. Name the templateActive-Cert-Template. Save it.
Device Provisioning
- Add configuration for
test-device. - In the templates field, add
Active-Cert-Template. Save. - Go to
PKI->Certificates. - Expected Result: You should see a brand new certificate automatically generated for
test-device. Its status should be valid (not revoked).
Active Mutation Locks
- Go back to
Configuration->Templatesand editActive-Cert-Template(which is now assigned to an active device). - Change the Type to
Generic. Try to save. - Expected Result: Validation error: "You cannot change the template type from certificate on an active template."
- Change the CA to
CA-2. Try to save. - Expected Result: Validation error blocking the CA change.
- Change the Blueprint to
Blueprint-2(ensure you also change the CA so they match, triggering the active lock). Try to save. - Expected Result: Validation error blocking the Blueprint change.
Revocation on Removal
- Go to the Configuration for
test-device. - Remove
Active-Cert-Templateentirely from the templates list. Save. - Go to
PKI->Certificatesand locate the device's certificate. - Expected Result: The certificate should still exist in the database, but its status should now be marked as Revoked.
Context Configuration Injection
-
Go to
Configuration->Templates, openActive-Cert-Template, and copy its UUID from the URL bar (removing the dashes so it is a 32-character hex string). -
In the JSON configuration editor for the template, add a configuration block that references the certificate's UUID variables:
{ "files": [ { "path": "{{ cert_<uuid>_path }}", "mode": "0600", "contents": "{{ cert_<uuid>_pem }}" } ] }(Note: Replace
<uuid>with the actual 32-character hex string of the template). -
Click Save.
-
Go back to the Configuration page for
test-device(which has this template assigned) and click thePreview configurationbutton. -
Expected Result: The variables should be successfully resolved. In the preview, you should see the generated path (e.g.,
/etc/x509/cert-<uuid>.pem) and the literal-----BEGIN CERTIFICATE-----text instead of the raw{{ }}template tags.
https://github.com/user-attachments/assets/bb39d802-2782-40df-90df-4bd248f58655
[!IMPORTANT]
Review skipped
Auto reviews are limited based on label configuration.
:label: Required labels (at least one) (1)
- ai-review
:no_entry_sign: Excluded labels (none allowed) (1)
- invalid
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID:
6602a54c-6dee-448f-a842-5d7dbfbcaac9You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- [ ] 🔍 Trigger review
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds standalone X.509 certificate-generator templates with CA and optional blueprint certificate relations. Adds relational DeviceCertificate bindings for generation, assignment, renewal, revocation, and configuration context injection. Adds API, admin, autocomplete, device-page, and template-form support. Device name or MAC changes can trigger asynchronous certificate replacement and notifications. Organization and mutation protections, migrations, tests, and documentation are included.
Estimated code review effort: 5 (Critical) | ~120 minutes
Merge Risk: 🟡 Moderate · up to 30ff1
The certificate-template feature introduces a bounded correctness risk because partial device saves can emit management-IP change events for values that were not persisted and may emit them again later; one concurrency test may also fail to observe setup data reliably. These issues should be fixed or explicitly accepted before merging.
Suggested reviewers: nemesifier, pandafy
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title uses the required [feature] prefix and clearly describes the standalone X.509 Certificate Generator Templates added by the pull request. |
| Description check | ✅ Passed | The description includes the checklist, linked issues, change summary, manual test plan, and a screenshot reference. It does not explicitly confirm the Anti AI Spam Policy item or use a separate Scree… |
| Linked Issues check | ✅ Passed | The changes address the linked objectives for certificate template fields and validation [#1356], DeviceCertificate modeling [#1377], admin integration [#1357], REST API support [#1361], certificate l… |
| Out of Scope Changes check | ✅ Passed | The code, tests, migrations, admin/API changes, documentation, UI changes, and VPN refactoring support the linked certificate-template and certificate-lifecycle objectives. No unrelated code changes a… |
| Ui Changes, Regression Test, Docs | ✅ Passed | PASS: The PR changes the admin UI, JavaScript, CSS, and device template rendering. The description includes a GitHub user-attachment MP4 screen recording, and the manual test plan describes the UI flo… |
Full details: Description check
Explanation
The description includes the checklist, linked issues, change summary, manual test plan, and a screenshot reference. It does not explicitly confirm the Anti AI Spam Policy item or use a separate Screenshot heading, but the required information is otherwise substantially complete.
Full details: Linked Issues check
Explanation
The changes address the linked objectives for certificate template fields and validation [#1356], DeviceCertificate modeling [#1377], admin integration [#1357], REST API support [#1361], certificate lifecycle management [#1358], UUID-namespaced configuration variables [#1360], and hardware-change regeneration [#1359]. Tests and documentation cover the stated behavior.
Full details: Out of Scope Changes check
Explanation
The code, tests, migrations, admin/API changes, documentation, UI changes, and VPN refactoring support the linked certificate-template and certificate-lifecycle objectives. No unrelated code changes are evident. The ignored SVG file is not relevant to the linked objectives.
Full details: Ui Changes, Regression Test, Docs
Explanation
PASS: The PR changes the admin UI, JavaScript, CSS, and device template rendering. The description includes a GitHub user-attachment MP4 screen recording, and the manual test plan describes the UI flow and expected before/after states. The feature diff adds regression coverage in test_template.py, test_api.py, test_device.py, test_admin.py, and Selenium tests for certificate fields and provisioning. The PR also adds docs/user/certificate-templates.rst and updates the templates, settings, REST API, introduction, and documentation index.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Commit unit tests in branch
issues/1356-extend-abstract-template
Comment @coderabbitai help to get the list of available commands.
@coderabbitai review
Review triggered. Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.✅ Actions performed
Code Review Summary
Status: No Issues Found | Recommendation: Merge
Files Reviewed (6 files)
.github/ISSUE_TEMPLATE/bug_report.md.github/workflows/ci.ymlopenwisp_controller/config/admin.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/connection/base/models.pyopenwisp_controller/connection/tests/test_selenium.py
Previous Review Summaries (16 snapshots, latest commit 06a0528)
Current summary above is authoritative. Previous snapshots are kept for context only.
Previous review (commit 06a0528)
Status: 1 Issue Found | Recommendation: Address before merge
Overview
| Severity | Count |
|---|---|
| CRITICAL | 0 |
| WARNING | 1 |
| SUGGESTION | 0 |
Issue Details (click to expand)
WARNING
| File | Line | Issue |
|---|---|---|
openwisp_controller/config/base/device.py |
396 | Behavior fix lacks a regression test for the dirty-management_ip partial-save case |
Files Reviewed (8 files, incremental since 570e193)
docs/user/certificate-templates.rstdocs/user/settings.rstopenwisp_controller/config/base/device.py- 1 issueopenwisp_controller/config/static/config/img/help.svg(deleted, unreferenced asset)openwisp_controller/config/tests/test_device.pyopenwisp_controller/pki/api/views.pyopenwisp_controller/pki/base/models.pyopenwisp_controller/pki/tests/test_api.py
The concurrency hardening for Cert.revoke()/renew() (row locks, idempotent revoke, renew-of-revoked guard surfacing as a 400 with a new regression test), the management_ip_changed update_fields gating, and the docs updates look correct and consistent with repository patterns. The only gap: the _check_management_ip_changed() fix has no dedicated regression test for the partial-save scenario requested in review.
Fix these issues in Kilo Cloud
Previous review (commit 570e193)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (2 files)
openwisp_controller/pki/base/models.pyopenwisp_controller/pki/tests/test_models.py
Previous review (commit faf5987)
Status: 1 Issue Found | Recommendation: Address before merge
Overview
| Severity | Count |
|---|---|
| CRITICAL | 0 |
| WARNING | 1 |
| SUGGESTION | 0 |
Issue Details (click to expand)
WARNING
| File | Line | Issue |
|---|---|---|
openwisp_controller/pki/base/models.py |
78 | save() now enforces CA-signature verification for every new cert and can raise an uncaught ValidationError on user-supplied certificates not signed by the selected CA (can surface as a 500 in the PKI API) |
Files Reviewed (4 files)
openwisp_controller/pki/base/models.py- 1 issueopenwisp_controller/config/tests/test_template.py- 0 issuesopenwisp_controller/pki/tests/test_api.py- 0 issuesopenwisp_controller/pki/tests/test_models.py- 0 issues
Fix these issues in Kilo Cloud
Previous review (commit e74169c)
Status: 3 Issues Found | Recommendation: Address before merge
Overview
| Severity | Count |
|---|---|
| CRITICAL | 3 |
| WARNING | 0 |
| SUGGESTION | 0 |
Issue Details (click to expand)
CRITICAL
| File | Line | Issue |
|---|---|---|
openwisp_controller/config/tests/test_template.py |
725 | test_clear_is_atomic_when_revocation_fails fails: template removal and cert revocation are not atomic — manage_device_certs() defers the DeviceCertificate cleanup with transaction.on_commit(), so a revocation failure cannot roll back the removal |
openwisp_controller/config/tests/test_template.py |
1602 | test_cert_copies_ca_extensions fails: CA extensions are not copied to generated certificates (get_client_extensions() returns only DEFAULT_CLIENT_EXTENSIONS when no blueprint is set) |
openwisp_controller/config/tests/test_template.py |
1619 | test_cert_context_uses_join fails: get_cert_context() issues 4 queries (2 per-dc.cert FK lookups) instead of 2 because device_certificate_relations is not fetched with select_related("cert") |
Files Reviewed (1 file, incremental since 8ce1c6b)
openwisp_controller/config/tests/test_template.py- 3 issues
The latest commit 4f4f647 [tests] Added failing tests adds four tests, three of which fail against the current implementation (see above); the PR is not mergeable until the corresponding fixes land so these tests pass. test_no_blueprint_cert_uses_current_ca_key (line 1622) depends on whether Ca.renew() regenerates the CA keypair: _build_cert() keeps the in-memory CA instance, so if renewal rotates the key, that test fails as well.
Fix these issues in Kilo Cloud
Previous review (commit 4f4f647)
Status: 3 Issues Found | Recommendation: Address before merge
Overview
| Severity | Count |
|---|---|
| CRITICAL | 3 |
| WARNING | 0 |
| SUGGESTION | 0 |
Issue Details (click to expand)
CRITICAL
| File | Line | Issue |
|---|---|---|
openwisp_controller/config/tests/test_template.py |
725 | test_clear_is_atomic_when_revocation_fails fails: template removal and cert revocation are not atomic — manage_device_certs() defers the DeviceCertificate cleanup with transaction.on_commit(), so a revocation failure cannot roll back the removal |
openwisp_controller/config/tests/test_template.py |
1602 | test_cert_copies_ca_extensions fails: CA extensions are not copied to generated certificates (get_client_extensions() returns only DEFAULT_CLIENT_EXTENSIONS when no blueprint is set) |
openwisp_controller/config/tests/test_template.py |
1619 | test_cert_context_uses_join fails: get_cert_context() issues 4 queries (2 per-dc.cert FK lookups) instead of 2 because device_certificate_relations is not fetched with select_related("cert") |
Files Reviewed (1 file, incremental since 8ce1c6b)
openwisp_controller/config/tests/test_template.py- 3 issues
The latest commit 4f4f647 [tests] Added failing tests adds four tests, three of which fail against the current implementation (see above); the PR is not mergeable until the corresponding fixes land so these tests pass. test_no_blueprint_cert_uses_current_ca_key (line 1622) depends on whether Ca.renew() regenerates the CA keypair: _build_cert() keeps the in-memory CA instance, so if renewal rotates the key, that test fails as well.
Fix these issues in Kilo Cloud
Previous review (commit 8ce1c6b)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (1 file, incremental since 30ff1027)
docs/user/templates.rst
Previous review (commit 30ff102)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (4 files, incremental since 9d134d6)
openwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/pki/tests/test_admin.py
Previous review (commit 9d134d6)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (3 files, incremental since c789eca)
docs/user/certificate-templates.rstdocs/user/settings.rstopenwisp_controller/config/tests/test_template.py
Previous review (commit c789eca)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (1 file, incremental since 6727eac)
openwisp_controller/pki/tests/test_admin.py
Previous review (commit 6727eac)
Status: 1 Issue Found | Recommendation: Address before merge
Overview
| Severity | Count |
|---|---|
| CRITICAL | 0 |
| WARNING | 1 |
| SUGGESTION | 0 |
Issue Details (click to expand)
WARNING
| File | Line | Issue |
|---|---|---|
openwisp_controller/pki/tests/test_admin.py |
176 | resolve(url) is passed a URL that includes the query string, so django.urls.resolve() raises Resolver404 and the two new forged-param changelist regressions error out instead of testing the fix (same defect at line 225) |
Files Reviewed (10 files, incremental since 0a1e011)
AGENTS.mddocs/developer/installation.rstdocs/index.rstopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/whois/tests/tests.pyopenwisp_controller/connection/tests/test_selenium.pyopenwisp_controller/geo/tests/test_selenium.pyopenwisp_controller/pki/admin.pyopenwisp_controller/pki/tests/test_admin.pyopenwisp_controller/tests/test_selenium.py
The P1 concern raised on pki/admin.py (forged app_label/model_name/field_name params exposing shared CAs and certificates on non-autocomplete admin routes) is addressed in this increment: _source_allows_shared_relation() is now restricted to the admin:autocomplete route, verifies view permission on the source admin, and regression tests were added for forged changelist, change, and delete requests on both Ca and Cert.
Fix these issues in Kilo Cloud
Previous review (commit 0a1e011)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (4 files, incremental since 0b0a252)
openwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.py
Previous review (commit 0b0a252)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (12 files)
docs/user/rest-api.rstdocs/user/settings.rstopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/static/config/js/switcher.jsopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/pki/api/views.pyopenwisp_controller/pki/tests/test_api.py
Previous review (commit 881f1f8)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (4 files)
openwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_vpn.py
Previous review (commit 0fb2397)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (4 files)
openwisp_controller/config/base/device_certificate.pyopenwisp_controller/pki/base/models.pyopenwisp_controller/pki/tests/test_admin.pyopenwisp_controller/pki/tests/test_api.py
Previous review (commit dc53718)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (4 files)
docs/developer/extending.rstdocs/user/certificate-templates.rstdocs/user/settings.rstdocs/user/templates.rst
Previous review (commit 1f6fe30)
Status: No Issues Found | Recommendation: Merge
Files Reviewed (4 files)
docs/developer/extending.rstdocs/user/certificate-templates.rstdocs/user/settings.rstdocs/user/templates.rst
Reviewed by balanced · Input: 39.7K · Output: 16.6K · Cached: 877.8K
[!CAUTION] Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.
Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/openwisp/openwisp-controller/issues/comments/4548211157","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- review_stack_entry_start -->\n\n[](https://app.coderabbit.ai/change-stack/openwisp/openwisp-controller/pull/1378?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)\n\n<!-- review_stack_entry_end -->\n<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->\n\n> [!NOTE]\n> Currently processing new changes in this PR. This may take a few minutes, please wait...\n> \n> <details>\n> <summary>⚙️ Run configuration</summary>\n> \n> **Configuration used**: Organization UI\n> \n> **Review profile**: ASSERTIVE\n> \n> **Plan**: Pro\n> \n> **Run ID**: `33bb61f8-c083-446e-8e45-44d753e7ff7b`\n> \n> </details>\n> \n> <details>\n> <summary>📥 Commits</summary>\n> \n> Reviewing files that changed from the base of the PR and between dc55622dfd09741ac51aad38afaaa206714ca875 and 25f1a213225299ecb5dc0ae4960630f68f8d8480.\n> \n> </details>\n> \n> <details>\n> <summary>📒 Files selected for processing (3)</summary>\n> \n> * `openwisp_controller/config/base/template.py`\n> * `openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py`\n> * `tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py`\n> \n> </details>\n> \n> ```ascii\n> __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________\n> < I've seen things you people wouldn't believe. Inefficient loops on fire off the shoulder of Orion. I've observed algorithms unfold in the dark near the Tannhäuser Gate, and watched data structures dissolve into the void of garbage collection. All those moments will be lost in my transient GPU cache, like tears in rain. >\n> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n> \\\n> \\ (\\__/)\n> (•ㅅ•)\n> / づ\n> ```\n\n<!-- end of auto-generated comment: review in progress by coderabbit.ai -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>🧪 Generate unit tests (beta)</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-4548221491\"} --> Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"6ba7b810-9dad-11d1-80b4-00c04fd430c8\", \"radioGroupId\": \"utg-output-choice-group-4548221491\"} --> Commit unit tests in branch `issues/1356-extend-abstract-template`\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=openwisp/openwisp-controller&utm_content=1378)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":3,"signal":{},"retries":3,"retryAfter":16}}}
{
"failures": [
{
"type": "Build/Infrastructure/Other",
"message": "Migrations check failed! Models' changes not migrated, please run './manage.py makemigrations' to solve the issue!",
"details": "The CI environment detected that the database migrations are out of sync. This is indicated by the error message 'Migrations check failed! Models' changes not migrated, please run './manage.py makemigrations' to solve the issue!' and the mention of a specific migration file '0005_user_expiration_date_user_user_active_expiry_idx.py'."
}
]
}
CI Failure Analysis
Hello @stktyagi, (Analysis for commit 25f1a21)
- Migrations Out of Sync: The CI build failed because the database migrations are not up-to-date. This is indicated by the error message "Migrations check failed! Models' changes not migrated, please run './manage.py makemigrations' to solve the issue!".
Fix: Run ./manage.py makemigrations to generate the necessary migration files and then commit them to the repository.
Migrations Check Failed
Hello @stktyagi, (Analysis for commit a795e09)
The CI failed because there are unapplied database migrations. This means that the database schema is out of sync with the current state of the code.
Fix: Run the following command to apply the pending migrations:
./manage.py makemigrations
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).
@coderabbitai full review
Full review triggered.✅ Actions performed
Migrations Check Failed
Hello @stktyagi, (Analysis for commit b946d26)
The CI failed because there are unapplied database migrations.
Failure: Migrations check failed! Models' changes not migrated, please run './manage.py makemigrations' to solve the issue!
Fix: Run the following command to generate the missing migrations:
./manage.py makemigrations
Coverage is 98.089% — issues/1356-extend-abstract-template into gsoc26-x509-certificate-generator-templates. No base build found for gsoc26-x509-certificate-generator-templates.
Test Failures in OpenWISP Controller CI
Hello @stktyagi, (Analysis for commit cae38a5)
There are test failures in the CI pipeline:
- Test Failure:
openwisp_controller.subnet_division.tests.test_admin.TestTransactionDeviceAdmin.test_vpn_template_switch_checksum_dbfailed withopenwisp_controller.config.models.Config.DoesNotExist: Config matching query does not exist.
- Fix: This indicates that the test is trying to retrieve a
Configobject that does not exist in the database. Ensure that aConfigobject is created and properly associated before this test is executed.
- Test Failure:
openwisp_controller.config.tests.test_api.TestConfigApi.test_template_list_api_filterfailed withAssertionError: 15 != 13. This failure occurred twice, once for filtering by organization ID and once for filtering by organization slug.
- Fix: The test expects a certain number of results (13), but received 15. This suggests an issue with how templates are being filtered or counted. Review the
test_template_list_api_filterand_assert_template_list_filterfunctions inopenwisp_controller/config/tests/test_api.pyto understand why the count is incorrect and adjust the filtering logic or the assertion.
@coderabbitai full review
Full review triggered.✅ Actions performed
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).
Test Query Count Mismatch
Hello @stktyagi, (Analysis for commit 02912a0)
The CI failure indicates a test failure in test_cert_delete_api within the openwisp_controller.pki.tests.test_api module.
Failure: The test failed because it expected 7 database queries but encountered 8.
Reason:
The traceback shows an additional query (query #8: DELETE FROM "openwisp_users_organization" WHERE "openwisp_users_organization"."id" IS NULL LIMIT 21) that was not anticipated by the test. This suggests a potential issue with how organization data is being handled or cleaned up during the test.
Fix:
You need to investigate why an extra query is being executed, particularly the one involving openwisp_users_organization with a NULL ID. This might be due to an unintended side effect of the deletion process or a test setup issue. Adjust the test to account for this query or fix the underlying cause if it indicates a bug.
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).
@coderabbitai full review
Full review triggered.✅ Actions performed