Skip to content

fix: format group member expiry dates - #1349

Merged
TimKnight01 merged 5 commits into
gitlabform:mainfrom
w3lld1:fix/group-members-expires-at-date
Jul 14, 2026
Merged

TimKnight01 merged 5 commits into
gitlabform:mainfrom
w3lld1:fix/group-members-expires-at-date

Conversation

@w3lld1

@w3lld1 w3lld1 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • normalize group_members expires_at values to GitLab's YYYY-MM-DD string format before comparing or saving user memberships
  • apply the same normalization to group_members.groups / share-with-group expiry values
  • add focused unit coverage for date, string, and missing expiry values

Fixes #1320

Validation

  • uv run qa lint ruff gitlabform/processors/group/group_members_processor.py tests/unit/processors/test_group_members_processor.py
  • uv run qa format --check gitlabform/processors/group/group_members_processor.py tests/unit/processors/test_group_members_processor.py
  • uv run qa test tests/unit/processors/test_group_members_processor.py
  • uv run qa test tests/unit

I did not run acceptance tests because they require a disposable GitLab instance/Docker setup.

@w3lld1
w3lld1 requested review from amimas and gdubicki as code owners July 9, 2026 20:49
@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 9, 2026 20:49 — with GitHub Actions Error
@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 9, 2026 20:49 — with GitHub Actions Error
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.36%. Comparing base (be7316d) to head (508f328).

Files with missing lines Patch % Lines
...abform/processors/group/group_members_processor.py 70.00% 3 Missing ⚠️

❌ Your project check has failed because the head coverage (68.36%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (be7316d) and HEAD (508f328). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (be7316d) HEAD (508f328)
unittests 2 0
integration 4 2
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1349      +/-   ##
==========================================
- Coverage   78.24%   68.36%   -9.88%     
==========================================
  Files          83       83              
  Lines        4229     4236       +7     
==========================================
- Hits         3309     2896     -413     
- Misses        920     1340     +420     
Flag Coverage Δ
integration 68.36% <70.00%> (-6.43%) ⬇️
unittests ?
Files with missing lines Coverage Δ
...abform/processors/group/group_members_processor.py 82.46% <70.00%> (-1.89%) ⬇️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@w3lld1
w3lld1 force-pushed the fix/group-members-expires-at-date branch from 508f328 to 50ea2c7 Compare July 9, 2026 22:19
@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 9, 2026 22:19 — with GitHub Actions Error
@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 9, 2026 22:19 — with GitHub Actions Error
@w3lld1

w3lld1 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Added focused unit coverage for the date-expiry call sites to address the Codecov patch coverage failure. Re-ran locally:

  • uv run qa lint ruff gitlabform/processors/group/group_members_processor.py tests/unit/processors/test_group_members_processor.py
  • uv run qa format --check gitlabform/processors/group/group_members_processor.py tests/unit/processors/test_group_members_processor.py
  • uv run qa test tests/unit/processors/test_group_members_processor.py
  • uv run qa test tests/unit

@w3lld1

w3lld1 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

I checked the failing CE acceptance job. The failure is in tests/acceptance/standard/test_job_token_scope.py::TestProjectJobTokenScope::test__disable_limit_access_to_this_project with GitLab returning:\n\n400 Bad request - Job token scope cannot be disabled for this project because it is enforced for the instance. Contact your administrator to modify this setting.\n\nThis looks unrelated to this PR's group-member expiry date formatting change; the EE acceptance job and the unit/lint/build checks are passing. I did not push code changes for this because the failure appears to be caused by the CI GitLab CE instance configuration.

@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 10, 2026 14:28 — with GitHub Actions Error
@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 10, 2026 14:28 — with GitHub Actions Error
@w3lld1

w3lld1 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

CI follow-up: on the latest matrix run, CE now passes and the same unrelated instance-setting failure moved to the EE job. The EE log shows test__disable_limit_access_to_this_project failing because GitLab returns 400 Bad request - Job token scope cannot be disabled for this project because it is enforced for the instance; the remaining 219 EE tests passed (4 skipped, 3 rerun). This is the same CI GitLab configuration issue noted earlier, not a failure in the group-member expiry formatting path, so I have not changed the code.

@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 10, 2026 19:09 — with GitHub Actions Error
@w3lld1
w3lld1 requested a deployment to Integrate Pull Request July 10, 2026 19:09 — with GitHub Actions Waiting
@rickbrouwer

Copy link
Copy Markdown
Collaborator

Thanks!

One thing though: this now creates an inconsistency with project/members_processor.py, which still calls .strftime() unconditionally and would crash on a quoted date string. Could you resolve this by extracting _format_expires_at into a shared util and using it in both processors?

Nit: isinstance(expires_at, date) would be a bit clearer than hasattr(..., "strftime").

@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 12, 2026 12:41 — with GitHub Actions Error
@w3lld1
w3lld1 had a problem deploying to Integrate Pull Request July 12, 2026 12:41 — with GitHub Actions Error
@w3lld1

w3lld1 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the consistency issue in 962cf7b0:

  • moved expiry formatting to shared gitlabform.util.format_expires_at
  • used it in both group and project member processors
  • switched the type check to isinstance(expires_at, date)

Validation:

  • uv run qa lint ruff gitlabform/util.py gitlabform/processors/group/group_members_processor.py gitlabform/processors/project/members_processor.py tests/unit/processors/test_group_members_processor.py
  • uv run qa test tests/unit/processors/test_group_members_processor.py (5 passed)
  • uv run qa test tests/unit (226 passed)

@rickbrouwer

Copy link
Copy Markdown
Collaborator

Another small nit: since format_expires_at is now a module-level util rather than a private classmethod, the double underscore in the test names (test__format_expires_at_*) is a bit misleading. Renaming to test_format_expires_at_* and moving them to tests/unit/test_util.py would fit better. Wdyt?

@w3lld1
w3lld1 temporarily deployed to Integrate Pull Request July 12, 2026 16:58 — with GitHub Actions Inactive
@w3lld1
w3lld1 temporarily deployed to Integrate Pull Request July 12, 2026 16:58 — with GitHub Actions Inactive
@w3lld1

w3lld1 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Agreed — moved the three format_expires_at cases to tests/unit/test_utils.py and renamed them without the private-method double underscore in b503fe58.

Validation:

  • Ruff and format checks pass
  • focused tests: 6 passed
  • full unit suite: 228 passed

@TimKnight01
TimKnight01 merged commit 4f1f52a into gitlabform:main Jul 14, 2026
23 checks passed

This branch was previously deployed

1 inactive deployment
Integrate Pull Request — b503fe58 Deployed Jul 12, 2026 by w3lld1 via Acceptance Tests / GitLab Ultimate #105
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.

Date serialization error in group_members with expires_at field

3 participants