Skip to content

Conversation

@hmpf
Copy link
Contributor

@hmpf hmpf commented Oct 29, 2025

Scope and purpose

Make it easy to dump the contents of a view's HttpRequest to a logger.

This is useful for debugging http headers both in development and production, as the headers sent to Django are cleaned up and renamed before being made available to a view. Some webservers and proxies also tweak the headers.

Useful for debugging REMOTE_USER problems...

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

@hmpf hmpf requested a review from a team October 29, 2025 12:33
@hmpf hmpf self-assigned this Oct 29, 2025
@hmpf hmpf added the nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes) label Oct 29, 2025
@github-actions
Copy link

github-actions bot commented Oct 29, 2025

Test results

    27 files      27 suites   45m 14s ⏱️
 2 668 tests  2 668 ✅ 0 💤 0 ❌
19 734 runs  19 734 ✅ 0 💤 0 ❌

Results for commit 7256556.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.82%. Comparing base (1a69675) to head (7256556).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3636      +/-   ##
==========================================
+ Coverage   62.68%   62.82%   +0.14%     
==========================================
  Files         611      611              
  Lines       45102    45138      +36     
  Branches       43       43              
==========================================
+ Hits        28270    28357      +87     
+ Misses      16822    16771      -51     
  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.

Make it easy to dump the contents of a view's HttpRequest to a logger.
raise FieldDoesNotExist


def pp_request(request: HttpRequest, function, *attributes) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

While this adds some very nice functionality, this name sucks, IMNSHO.

I take it pp is meant to convey the concept of pretty-print (but it sounds awfully childish when pronounced). Since it doesn't actually "print" anything, at best this would be cognate with the function pprint.pformat(), so how about pformat_request() instead?

@hmpf hmpf requested a review from lunkwill42 October 30, 2025 12:32
@sonarqubecloud
Copy link

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

Labels

nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants