Skip to content

Fix bug where netmap views can't be saved or updated#3737

Merged
lunkwill42 merged 2 commits into5.16.xfrom
fix/3736-netmap-save-throws-an-error
Jan 28, 2026
Merged

Fix bug where netmap views can't be saved or updated#3737
lunkwill42 merged 2 commits into5.16.xfrom
fix/3736-netmap-save-throws-an-error

Conversation

@Simrayz
Copy link
Copy Markdown
Contributor

@Simrayz Simrayz commented Jan 27, 2026

Scope and purpose

Fixes #3736

This pull request

  • Fixes a CSRF token bug in the netmap AJAX calls (control_view.js and models.js)
  • Fixes a typo in the Netmap /nodepositions/update/ view, which seems to have been introduced in the re_path refactor back in september (oops)

The bug is solved by using a recommended approach for Django projects where AJAX calls are used in frontend code, i.e. https://docs.djangoproject.com/en/5.0/howto/csrf/. The bug is most likely caused by timing/rendering issues, where the dynamic rendering of the forms stops the csrf token from being added to the forms correctly. I added a new plugin csrf-utils that can be re-used if we get similar issues elsewhere.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • Wrote the commit message so that the first line continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • Based this pull request on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@Simrayz Simrayz requested a review from a team January 27, 2026 11:11
@Simrayz Simrayz self-assigned this Jan 27, 2026
@Simrayz Simrayz force-pushed the fix/3736-netmap-save-throws-an-error branch from eb9808a to d480f3d Compare January 27, 2026 11:20
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test results

    27 files      27 suites   46m 17s ⏱️
 2 778 tests  2 778 ✅ 0 💤 0 ❌
20 614 runs  20 614 ✅ 0 💤 0 ❌

Results for commit d480f3d.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.04%. Comparing base (5b8efb4) to head (d480f3d).
⚠️ Report is 3 commits behind head on 5.16.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           5.16.x    #3737      +/-   ##
==========================================
+ Coverage   63.03%   63.04%   +0.01%     
==========================================
  Files         614      614              
  Lines       45438    45438              
  Branches       43       43              
==========================================
+ Hits        28641    28646       +5     
+ Misses      16787    16782       -5     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

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

Nice solution! Especially forward thinking with adding the function to be used in future cases!

@lunkwill42 lunkwill42 merged commit 910f3c0 into 5.16.x Jan 28, 2026
20 checks passed
@lunkwill42 lunkwill42 deleted the fix/3736-netmap-save-throws-an-error branch January 28, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants