Skip to content

Conversation

@erictapen
Copy link
Contributor

When packaging drf-standardized-errors for Nixpkgs, I stumbled into this pytest failure:

...
python3.12-drf-standardized-errors> Running phase: pytestCheckPhase
python3.12-drf-standardized-errors> Executing pytestCheckPhase
python3.12-drf-standardized-errors> pytest flags: -m pytest
python3.12-drf-standardized-errors> ============================= test session starts ==============================
python3.12-drf-standardized-errors> platform linux -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
python3.12-drf-standardized-errors> django: version: 4.2.18, settings: tests.settings (from env)
python3.12-drf-standardized-errors> rootdir: /build/source
python3.12-drf-standardized-errors> configfile: tox.ini
python3.12-drf-standardized-errors> testpaths: tests
python3.12-drf-standardized-errors> plugins: django-4.9.0
python3.12-drf-standardized-errors> collected 120 items                                                            
python3.12-drf-standardized-errors> tests/test_exception_handler.py ...........                              [  9%]
python3.12-drf-standardized-errors> tests/test_flatten_errors.py .......                                     [ 15%]
python3.12-drf-standardized-errors> tests/test_openapi.py .....................................              [ 45%]
python3.12-drf-standardized-errors> tests/test_openapi_utils.py ........................F...........         [ 75%]
python3.12-drf-standardized-errors> tests/test_openapi_validation_errors.py ........................         [ 95%]
python3.12-drf-standardized-errors> tests/test_settings.py .....                                             [100%]
python3.12-drf-standardized-errors> =================================== FAILURES ===================================
python3.12-drf-standardized-errors> ______________________ test_char_fields_with_error_codes _______________________
python3.12-drf-standardized-errors>     def test_char_fields_with_error_codes():
python3.12-drf-standardized-errors>         (char, slug, regex, uuid, ip) = get_form_fields_with_error_codes(CharForm())
python3.12-drf-standardized-errors>     
python3.12-drf-standardized-errors>         assert char.error_codes == {
python3.12-drf-standardized-errors>             "required",
python3.12-drf-standardized-errors>             "null_characters_not_allowed",
python3.12-drf-standardized-errors>             "min_length",
python3.12-drf-standardized-errors>             "max_length",
python3.12-drf-standardized-errors>         }
python3.12-drf-standardized-errors>         assert slug.error_codes == {"invalid", "null_characters_not_allowed"}
python3.12-drf-standardized-errors>         assert regex.error_codes == {"invalid", "required", "null_characters_not_allowed"}
python3.12-drf-standardized-errors>         assert uuid.error_codes == {"invalid", "required", "null_characters_not_allowed"}
python3.12-drf-standardized-errors> >       assert ip.error_codes == {"invalid", "null_characters_not_allowed"}
python3.12-drf-standardized-errors> E       AssertionError: assert {'invalid', '..._not_allowed'} == {'invalid', '..._not_allowed'}
python3.12-drf-standardized-errors> E         
python3.12-drf-standardized-errors> E         Extra items in the left set:
python3.12-drf-standardized-errors> E         'max_length'
python3.12-drf-standardized-errors> E         Use -v to get more diff
python3.12-drf-standardized-errors> tests/test_openapi_utils.py:518: AssertionError
python3.12-drf-standardized-errors> =========================== short test summary info ============================
python3.12-drf-standardized-errors> FAILED tests/test_openapi_utils.py::test_char_fields_with_error_codes - AssertionError: assert {'invalid', '..._not_allowed'} == {'invalid', '..._n...
python3.12-drf-standardized-errors> ======================== 1 failed, 119 passed in 1.91s =========================

Is this just an oversight or does it hint a problem on my side?

@ghazi-git
Copy link
Owner

Thank you @erictapen for opening this PR.

This is because of the CVE fixed in django 4.2.18/5.0.11/5.1.5 last month. The fix added a default max_length to GenericIPAddressField, and that resulted in the test failure.

Can you update the PR so that the error code max_length is expected when django >= 4.2 rather than always? the package still declares support for django 3.2/4.0/4.1 (and would continue for a while even though they are EOL)

@erictapen
Copy link
Contributor Author

Ah good to know. Is this better?

@codecov
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.49%. Comparing base (ce03d4a) to head (96a42ba).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage   99.49%   99.49%           
=======================================
  Files          10       10           
  Lines         789      789           
  Branches      152      152           
=======================================
  Hits          785      785           
  Misses          1        1           
  Partials        3        3           

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

@ghazi-git
Copy link
Owner

All good, thank you very much

@ghazi-git ghazi-git merged commit 760e5d5 into ghazi-git:main Feb 17, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants