Skip to content

Conversation

AlanCoding
Copy link
Member

@AlanCoding AlanCoding commented Oct 2, 2025

Description

Looking to get DAB CI passing with Django 5 & 4 for the compatibility phase.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test update
  • Refactoring (no functional changes)
  • Development environment change
  • Configuration change

Note

Add Django 5.2 support with Django 4 compatibility, updating CI/tox matrices, relaxing/pinning requirements, adding a help_text migration, and adapting resource prefetch logic with new tests.

  • Compatibility: Django 5.2 + 4.x
    • ansible_base/resource_registry/fields.py: implement get_prefetch_querysets(...) and add a Django 4-compatible get_prefetch_queryset(...) shim for the custom one-to-one descriptor.
    • ansible_base/rbac/migrations/0009_objectrole_help_text_change.py: migration updating ObjectRole users/teams ManyToMany help_text.
  • CI/Tooling
    • .github/workflows/ci.yml: add matrix envs py310-django4, py311-django4, py312-django4.
    • pyproject.toml (tox): add corresponding envs and include them in the test label.
    • requirements/requirements.in|all.txt|dev.txt: relax to Django>=4.2.21,<6.0 and pin to django==5.2.7 in compiled/dev.
    • requirements/updater.sh: add safety check to run from requirements/ and minor script hardening.
  • Tests
    • test_app/tests/resource_registry/models/test_resource_field.py: add prefetch tests across organization__resource via Inventory and to resource__content_type__resource_type; update imports.

Written by Cursor Bugbot for commit 59c8734. This will update automatically on new commits. Configure here.

@AlanCoding AlanCoding changed the title Try to run checks with Django 5.2 AAP-51350 Try to run checks with Django 5.2 Oct 2, 2025
@AlanCoding
Copy link
Member Author

Documenting:

FAILED test_app/tests/resource_registry/models/test_resource_field.py::test_resource_field_prefetch_related - AttributeError: 'NoneType' object has no attribute 'name'
FAILED test_app/tests/rbac/remote/test_service_api.py::test_list_role_user_assignments - AssertionError: assert None == 'd81556af-c82e-4659-bde4-b0905f1a696b'
 +  where 'd81556af-c82e-4659-bde4-b0905f1a696b' = str(UUID('d81556af-c82e-4659-bde4-b0905f1a696b'))
 +    where UUID('d81556af-c82e-4659-bde4-b0905f1a696b') = <Resource: Resource object (974)>.ansible_id
 +      where <Resource: Resource object (974)> = <User: rando>.resource
FAILED test_app/tests/resource_registry/test_resources_api_rest_client.py::test_sync_org_assignment - AssertionError: assert 'f7f63489-91a5-4a9a-8eaa-ba7e409e1375' == None
 +  where 'f7f63489-91a5-4a9a-8eaa-ba7e409e1375' = str(UUID('f7f63489-91a5-4a9a-8eaa-ba7e409e1375'))
 +    where UUID('f7f63489-91a5-4a9a-8eaa-ba7e409e1375') = <Resource: Resource object (1509)>.ansible_id
 +      where <Resource: Resource object (1509)> = <User: _system>.resource
 +        where <User: _system> = RoleUserAssignment(pk=122).created_by
FAILED test_app/tests/resource_registry/test_resources_api.py::test_resource_summary_fields - AssertionError: assert 'resource' in {'modified_by': {'id': 878, 'username': '_system', 'first_name': '', 'last_name': ''}, 'created_by': {'id': 878, 'username': '_system', 'first_name': '', 'last_name': ''}}
FAILED test_app/tests/resource_registry/test_resources_api_rest_client.py::test_sync_obj_assignment - AssertionError: assert '1dc0fc62-4480-4198-9d7b-f9f5acee18c9' == None
 +  where '1dc0fc62-4480-4198-9d7b-f9f5acee18c9' = str(UUID('1dc0fc62-4480-4198-9d7b-f9f5acee18c9'))
 +    where UUID('1dc0fc62-4480-4198-9d7b-f9f5acee18c9') = <Resource: Resource object (1515)>.ansible_id
 +      where <Resource: Resource object (1515)> = <User: _system>.resource
 +        where <User: _system> = RoleUserAssignment(pk=123).created_by
FAILED test_app/tests/resource_registry/test_resources_api_rest_client.py::test_list_user_assignments - AssertionError: User assignment not found in list results
assert False
FAILED test_app/tests/resource_registry/test_resources_api_rest_client.py::test_list_team_assignments - AssertionError: Team assignment not found in list results
assert False
FAILED test_app/tests/rbac/remote/test_service_api.py::TestCreatedByAnsibleIdAllowNull::test_list_assignments_shows_created_by_when_present - AssertionError: assert None == 'de23093f-5d72-4de3-bced-660c8b0b1817'
 +  where 'de23093f-5d72-4de3-bced-660c8b0b1817' = str(UUID('de23093f-5d72-4de3-bced-660c8b0b1817'))
 +    where UUID('de23093f-5d72-4de3-bced-660c8b0b1817') = <Resource: Resource object (1105)>.ansible_id
 +      where <Resource: Resource object (1105)> = <User: assignment-creator>.resource
FAILED test_app/tests/rbac/remote/test_service_api.py::TestCreatedByAnsibleIdAllowNull::test_list_assignments_shows_null_created_by_when_null - assert None is not None
===== 9 failed, 2619 passed, 13 xfailed, 62 warnings in 559.17s (0:09:19) ======

@AlanCoding
Copy link
Member Author

Link #213

@AlanCoding AlanCoding marked this pull request as ready for review October 6, 2025 14:23
cursor[bot]

This comment was marked as outdated.

@AlanCoding
Copy link
Member Author

@ttuffin asking for your advisement on SonarCloud coverage data here. This reports that the new method isn't covered. This is somewhat obvious, because it is added for compatibility, and whatever the existing config is doing seems to only get coverage from one run. But clearly different runs in the matrix will cover different lines in code - otherwise why would we have a matrix?!

This is where a coverage requirement becomes very murky, as it gets highly highly configuration dependent. Do you want coverage to be gathered from all runs and combined? We have a clear preference, which is that we only "care" about Django 5, as the compatibility stuff is temporary, but cannot be avoided. Getting coverage for version-specific stuff is extra work and doesn't necessarily provide any value.

cursor[bot]

This comment was marked as outdated.

@AlanCoding AlanCoding changed the title AAP-51350 Try to run checks with Django 5.2 AAP-51350 Support Django 5.2 as well as Django 4.y Oct 6, 2025
cursor[bot]

This comment was marked as outdated.

Copy link

github-actions bot commented Oct 6, 2025

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

Copy link

sonarqubecloud bot commented Oct 6, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
41.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@AlanCoding
Copy link
Member Author

Tests I added meaningfully covered the non-trivial code related to processing of multiple querysets passed in. This seems pretty solid now.

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.

1 participant