Skip to content

[fix] Prevented autocomplete loop without an organization field - #569

Open
nemesifier wants to merge 1 commit into
masterfrom
fix-org-autocomplete-readonly-form
Open

[fix] Prevented autocomplete loop without an organization field#569
nemesifier wants to merge 1 commit into
masterfrom
fix-org-autocomplete-readonly-form

Conversation

@nemesifier

Copy link
Copy Markdown
Member

Checklist

Reference to Existing Issue

Related to openwisp/openwisp-ipam#239.

Description of Changes

Prevents the organization autocomplete script from traversing parents indefinitely when an admin page omits the Organization select. Adds Selenium coverage for the missing-field case.

Screenshot

N/A

@nemesifier nemesifier added the bug label Sep 2, 2026
@nemesifier nemesifier self-assigned this Sep 2, 2026
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

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: Team

Run ID: eeb23abe-f3a1-4f56-8ef2-90f2248f4800

📥 Commits

Reviewing files that changed from the base of the PR and between 2aed8eb and bedba10.

📒 Files selected for processing (2)
  • openwisp_users/static/openwisp-users/js/org-autocomplete.js
  • tests/testapp/tests/test_selenium.py

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (12)
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (2)
Ensure tests cover relevant success, error, boundary, and unusual input scenarios.

⚙️ CodeRabbit configuration file

Files:

  • tests/testapp/tests/test_selenium.py
Flag potential security vulnerabilities Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries Flag unused or redundant code Flag outdated or incorrect comments/docstrings Ensure new code handles err...

⚙️ CodeRabbit configuration file

Files:

  • openwisp_users/static/openwisp-users/js/org-autocomplete.js
  • tests/testapp/tests/test_selenium.py
🔇 Additional comments (2)
openwisp_users/static/openwisp-users/js/org-autocomplete.js (1)

13-15: LGTM!

tests/testapp/tests/test_selenium.py (1)

12-12: LGTM!

Also applies to: 21-22, 148-174


📝 Walkthrough

Walkthrough

The organization autocomplete script now exits when the organization select is absent. The Selenium test uses a book change page, removes the organization field, reloads the script, and verifies that no browser errors occur.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to bedba

This localized change prevents an autocomplete loop when the organization field is absent and adds coverage for that case; no actionable merge-blocking risk remains beyond normal checks and review.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Ui Changes, Regression Test, Docs ❌ Error The pull request changes client-side behavior in the Django admin UI. The new guard prevents the organization autocomplete script from hanging when select#id_organization is absent, and the added Se… Add before-and-after screenshots or a screen recording to the PR description. Show the affected admin page before the fix, when the missing organization field causes the autocomplete script to hang, and after the fix, when the page reloads …
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required [fix] prefix and clearly describes the autocomplete change when the organization field is absent.
Description check ✅ Passed The description includes the checklist, issue reference, change summary, and screenshot status. It explains the missing-field fix and Selenium coverage. The issue is marked as related rather than clos…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the checklist, issue reference, change summary, and screenshot status. It explains the missing-field fix and Selenium coverage. The issue is marked as related rather than closed, but the required issue reference is present.

Full details: Ui Changes, Regression Test, Docs

Explanation

The pull request changes client-side behavior in the Django admin UI. The new guard prevents the organization autocomplete script from hanging when select#id_organization is absent, and the added Selenium test exercises this browser scenario. The regression-test requirement is met. However, the authored PR description lists Screenshot: N/A, so it does not provide the required before-and-after screenshot or screen recording for an end-user-facing UI change. This is a bug fix, not a new feature, and no documentation update is required by the stated rules.

Resolution

Add before-and-after screenshots or a screen recording to the PR description. Show the affected admin page before the fix, when the missing organization field causes the autocomplete script to hang, and after the fix, when the page reloads without browser errors.

  • Fix all pre-merge checks with AI

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

@kilo-code-bot

kilo-code-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • openwisp_users/static/openwisp-users/js/org-autocomplete.js
  • tests/testapp/tests/test_selenium.py

The guard added in org-autocomplete.js prevents the infinite parent-traversal loop ($().prop("tagName") returns undefined and .parent() keeps returning an empty set when select#id_organization is absent) by returning early, which correctly addresses the reported bug without altering behavior on pages that do render the field. The new Selenium regression test simulates a page that omits the organization select and would time out (hang) before the patch and pass after it, so it is discriminating. Note: alignment with openwisp/openwisp-ipam#239 was assessed from the PR description, as the referenced issue could not be fetched from this environment.


Reviewed by balanced · Input: 50.4K · Output: 16K · Cached: 494.3K

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 98.142%. remained the same — fix-org-autocomplete-readonly-form into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: To do (general)

Development

Successfully merging this pull request may close these issues.

2 participants