Skip to content

fix: remove annotated models from safelist and annotate openedx models on PII#38712

Merged
bmtcril merged 12 commits into
openedx:masterfrom
Akanshu-2u:aaich/BOMS-572
Jun 12, 2026
Merged

fix: remove annotated models from safelist and annotate openedx models on PII#38712
bmtcril merged 12 commits into
openedx:masterfrom
Akanshu-2u:aaich/BOMS-572

Conversation

@Akanshu-2u

@Akanshu-2u Akanshu-2u commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description:

This PR fixes pii_check for edx-platform by adding missing model annotations and correcting the safelist so the annotation tool passes cleanly.

Changes:

  • Added/fixed inline PII annotations in the targeted edx-platform models (including no_pii and pii metadata where required).
  • Cleaned safelist conflicts by removing entries for models that are now annotated inline.
  • Restored required safelist entries for non-local, generated, and historical models so coverage is complete.
  • Fixed malformed annotation syntax in one model block.

Validation:

  • Ran the pii annotation check with lint and coverage.
  • Result: lint passed and coverage reached 100% (all eligible models annotated).

Private JIRA Link:

BOMS-572

@Akanshu-2u Akanshu-2u changed the title fix: remove annotated models from safelist and annotate openedx models on PII [Do not merge] fix: remove annotated models from safelist and annotate openedx models on PII Jun 5, 2026
@Akanshu-2u Akanshu-2u requested a review from Copilot June 5, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds/standardizes PII annotation markers on several Django models and refreshes the repository annotation safelist to reflect current coverage.

Changes:

  • Add .. no_pii: markers to multiple models’ docstrings.
  • Add explicit .. pii, .. pii_types, and .. pii_retirement metadata to models storing Apple identifiers and employee email addresses.
  • Update .annotation_safe_list.yml by removing older entries and adding a larger set of non-local/generated models.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
openedx/core/djangoapps/notifications/models.py Adds .. no_pii: annotation to NotificationPreference model docstring.
openedx/core/djangoapps/embargo/models.py Adds .. no_pii: annotation to GlobalRestrictedCountry model docstring.
openedx/core/djangoapps/discussions/models.py Fixes .. no_pii: directive formatting to include a space.
common/djangoapps/third_party_auth/models.py Annotates Apple migration identifiers as PII with type/retirement metadata.
common/djangoapps/student/models/user.py Adds .. no_pii: to history model and adds PII metadata docstring to AllowedAuthUser.
.annotation_safe_list.yml Removes older safelist blocks and adds/updates safelist coverage for many models.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .annotation_safe_list.yml Outdated
Comment on lines +260 to +264
# Via django-wiki https://github.com/openedx/django-wiki
wiki.Article:

# Additional non-local or generated models requiring safelist coverage
agreements.HistoricalUserAgreement:
".. no_pii:": "No PII"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

implemented

Model to store users' Apple Unique Identifier during migration
process of Apple team from edx Inc. to edx LLC.

.. pii: Contains Apple user identifiers (old_apple_id, transfer_id, new_apple_id).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not required


class AllowedAuthUser(TimeStampedModel):
"""
Tracks which employee email addresses are allowed to log in with password on a given site.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not required

@Akanshu-2u Akanshu-2u requested a review from Copilot June 5, 2026 08:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Comment thread .annotation_safe_list.yml
Comment thread .annotation_safe_list.yml
Comment on lines +252 to +260
# Additional non-local or generated models requiring safelist coverage
agreements.HistoricalUserAgreement:
".. no_pii:": "No PII"
assessment.HistoricalSharedFileUpload:
".. no_pii:": "No PII"
casbin_adapter.CasbinRule:
".. no_pii:": "No PII"
channel_integration.ApiResponseRecord:
".. no_pii:": "No PII"
Comment on lines 1061 to +1067
"""
Model to store users' Apple Unique Identifier during migration
process of Apple team from edx Inc. to edx LLC.

.. pii: Contains Apple user identifiers (old_apple_id, transfer_id, new_apple_id).
.. pii_types: external_service
.. pii_retirement: local_api
"""
Tracks which employee email addresses are allowed to log in with password on a given site.

.. pii: Contains employee email address.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove employee

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented

Model to store users' Apple Unique Identifier during migration
process of Apple team from edx Inc. to edx LLC.

.. pii: Contains Apple user identifiers (old_apple_id, transfer_id, new_apple_id).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

check if this change is required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

AppleMigrationUserIdInfo stores Apple user identifiers (old_apple_id, transfer_id, new_apple_id) which are external identity tokens uniquely tied to real users. Our policy requires all local models storing PII to be annotated inline. The external_service type and local_api retirement are consistent with how we annotate similar identity-linkage models.

@Akanshu-2u Akanshu-2u requested a review from ttak-apphelix June 8, 2026 11:46

@bmtcril bmtcril left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems ok at a glance, but it doesn't look like the annotation check is working correctly so there may be syntax problems not being caught. The check is reporting 0 models found for cms and lms:

code_annotations django_find_annotations \
	--config_file .pii_annotations.yml \
	--app_name cms \
	--coverage \
	--lint
Configured for report path: pii_report
Configured for source path: ./
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fs/__init__.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  __import__("pkg_resources").declare_namespace(__name__)  # type: ignore
Key BLOCK_STRUCTURES_SETTINGS 'STORAGE_CLASS' not found in storage settings {'COURSE_PUBLISH_TASK_DELAY': 30, 'TASK_DEFAULT_RETRY_DELAY': 30, 'TASK_MAX_RETRIES': 5}.Using default storage path.
Found safelist at .annotation_safe_list.yml. Reading.

Performing linting checks...
Linting passed without errors.

Model coverage report
----------------------------------------
Found 0 total models.
0 were eligible for annotation, 0 were annotated.
Coverage is 100.0%

@Akanshu-2u

Copy link
Copy Markdown
Contributor Author

This seems ok at a glance, but it doesn't look like the annotation check is working correctly so there may be syntax problems not being caught. The check is reporting 0 models found for cms and lms:

code_annotations django_find_annotations \
	--config_file .pii_annotations.yml \
	--app_name cms \
	--coverage \
	--lint
Configured for report path: pii_report
Configured for source path: ./
/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fs/__init__.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  __import__("pkg_resources").declare_namespace(__name__)  # type: ignore
Key BLOCK_STRUCTURES_SETTINGS 'STORAGE_CLASS' not found in storage settings {'COURSE_PUBLISH_TASK_DELAY': 30, 'TASK_DEFAULT_RETRY_DELAY': 30, 'TASK_MAX_RETRIES': 5}.Using default storage path.
Found safelist at .annotation_safe_list.yml. Reading.

Performing linting checks...
Linting passed without errors.

Model coverage report
----------------------------------------
Found 0 total models.
0 were eligible for annotation, 0 were annotated.
Coverage is 100.0%

Yes, this issue was previously identified and tracked in #38646 to fix the pii_check syntax. However, the corresponding PR intended to address it, #38667, was closed without any explanation and without resolving the underlying issue.

I followed up on the original issue with a comment (#38646 (comment)) requesting clarification, but I have not yet received a response.

At the moment, the only reason this PR is marked as "Do not merge" is that we are waiting for the pii_check fix to be implemented. Once that fix is in place, we will be able to verify this PR through the CI checks and proceed accordingly.

Note: For local testing purposes, I applied a temporary fix to the pii_check syntax issue and ran the checks against these changes. After confirming that everything passed successfully, I proceeded to raise this PR.

@Akanshu-2u Akanshu-2u requested a review from bmtcril June 10, 2026 05:31
@Akanshu-2u Akanshu-2u changed the title [Do not merge] fix: remove annotated models from safelist and annotate openedx models on PII fix: remove annotated models from safelist and annotate openedx models on PII Jun 11, 2026

@bmtcril bmtcril left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 Thanks for taking this on!

@Akanshu-2u

Copy link
Copy Markdown
Contributor Author

The CI got stuck so did a forced push.

@bmtcril bmtcril merged commit 1b338e7 into openedx:master Jun 12, 2026
41 of 42 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.

4 participants