Skip to content

feat: replace enterprise_support import with AccountSettingsReadOnlyF…#201

Closed
kiram15 wants to merge 5 commits intorelease-ulmofrom
kiram15/ENT-11510
Closed

feat: replace enterprise_support import with AccountSettingsReadOnlyF…#201
kiram15 wants to merge 5 commits intorelease-ulmofrom
kiram15/ENT-11510

Conversation

@kiram15
Copy link
Copy Markdown

@kiram15 kiram15 commented Mar 26, 2026

Removes the direct import of get_enterprise_readonly_account_fields from openedx.features.enterprise_support.utils in accounts/api.py and replaces it with a call to the AccountSettingsReadOnlyFieldsRequested openedx-filter. Adds the filter to OPEN_EDX_FILTERS_CONFIG. Updates tests to mock the filter instead of the old enterprise_support imports.

ENT-11510

Description

Describe what this pull request changes, and why. Include implications for people using this change.
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
OEP-19, and can be
linked here.

Useful information to include:

  • Which edX user roles will this change impact? Common user roles are "Learner", "Course Author",
    "Developer", and "Operator".
  • Include screenshots for changes to the UI (ideally, both "before" and "after" screenshots, if applicable).
  • Provide links to the description of corresponding configuration changes. Remember to correctly annotate these
    changes.

Supporting information

Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for testing this change.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
  • If your database migration can't be rolled back easily.

Copilot AI review requested due to automatic review settings March 26, 2026 22:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the user account settings update validation to use an openedx-filters hook for determining read-only fields (replacing the prior enterprise-support-based mechanism), and bumps edx-enterprise to pick up the corresponding filter step.

Changes:

  • Replace enterprise read-only account field logic with AccountSettingsReadOnlyFieldsRequested.run_filter in the accounts API.
  • Update/adjust unit tests for the new filter-based behavior and swap UTC handling to zoneinfo.
  • Bump edx-enterprise to 6.8.2 and introduce/update settings intended to configure OPEN_EDX_FILTERS_CONFIG and related LMS environment behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
requirements/edx/base.txt Bump edx-enterprise to 6.8.2 in base requirements.
requirements/edx/development.txt Bump edx-enterprise to 6.8.2 for dev requirements.
requirements/edx/testing.txt Bump edx-enterprise to 6.8.2 for test requirements.
requirements/edx/doc.txt Bump edx-enterprise to 6.8.2 for doc requirements.
requirements/constraints.txt Pin edx-enterprise to 6.8.2 in constraints.
openedx/core/djangoapps/user_api/accounts/api.py Use AccountSettingsReadOnlyFieldsRequested to compute additional read-only fields; switch UTC handling to zoneinfo.
openedx/core/djangoapps/user_api/accounts/tests/test_api.py Update tests to patch the new filter and validate read-only-field rejection; switch UTC handling to zoneinfo; update social platform test data.
lms/envs/production.py Add YAML token handling/merge behavior for OPEN_EDX_FILTERS_CONFIG.
lms/envs/common.py Add default OPEN_EDX_FILTERS_CONFIG and other settings changes (currently introduces multiple import-time NameError issues as noted in comments).

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

Comment thread lms/envs/common.py Outdated
Comment thread lms/envs/common.py Outdated
Comment thread lms/envs/common.py Outdated
Comment thread lms/envs/common.py Outdated
Comment thread lms/envs/common.py
Comment thread lms/envs/common.py
Comment thread lms/envs/common.py
Comment thread lms/envs/common.py Outdated
Comment thread lms/envs/common.py Outdated
Comment thread lms/envs/common.py Outdated
Copilot AI review requested due to automatic review settings April 9, 2026 15:29
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch from 7daf9c6 to a7a5a6f Compare April 9, 2026 15:29
Copy link
Copy Markdown

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 3 comments.


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

Comment on lines +196 to +199
plugin_readonly_fields, __ = AccountSettingsReadOnlyFieldsRequested.run_filter(
readonly_fields=set(),
user=user,
)
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The openedx-filters call site is missing the standard # .. filter_implemented_name: / # .. filter_type: annotations used elsewhere in the codebase for filter invocations, which are relied on for documentation/discovery. Add these two comment lines immediately above the run_filter call (see e.g. openedx/core/djangoapps/user_authn/views/login.py around the StudentLoginRequested.run_filter usage).

Copilot uses AI. Check for mistakes.
Comment thread lms/envs/common.py
Comment thread lms/envs/production.py
# Merge OPEN_EDX_FILTERS_CONFIG from YAML into the default defined in common.py.
# Pipeline steps from YAML are appended after steps defined in common.py.
# The fail_silently value from YAML takes precedence over the one in common.py.
for _filter_type, _filter_config in _YAML_TOKENS.get('OPEN_EDX_FILTERS_CONFIG', {}).items():
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

_YAML_TOKENS.get('OPEN_EDX_FILTERS_CONFIG', {}) will return None if the YAML explicitly sets OPEN_EDX_FILTERS_CONFIG: null, which would raise an AttributeError on .items(). Consider using (_YAML_TOKENS.get('OPEN_EDX_FILTERS_CONFIG') or {}) (and ideally validating it’s a dict) before iterating to avoid startup-time crashes from a misconfigured YAML.

Suggested change
for _filter_type, _filter_config in _YAML_TOKENS.get('OPEN_EDX_FILTERS_CONFIG', {}).items():
_open_edx_filters_config = _YAML_TOKENS.get('OPEN_EDX_FILTERS_CONFIG') or {}
if not isinstance(_open_edx_filters_config, dict):
raise ImproperlyConfigured('OPEN_EDX_FILTERS_CONFIG must be a dict')
for _filter_type, _filter_config in _open_edx_filters_config.items():

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings May 4, 2026 15:57
Copy link
Copy Markdown

Copilot AI left a comment

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 13 out of 13 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

requirements/edx/base.txt:15

  • The PR description focuses on switching the enterprise_support import to an openedx-filter, but this PR also includes a broad dependency refresh across multiple requirements files (including major version bumps). If this is intentional, it should be called out explicitly in the PR description; otherwise consider splitting the requirements upgrades into a separate PR to reduce review/rollback risk.
    # via -r requirements/edx/kernel.in
aiohappyeyeballs==2.6.1
    # via aiohttp
aiohttp==3.13.5
    # via geoip2
aiosignal==1.4.0
    # via aiohttp
amqp==5.3.1

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

Comment on lines 38 to 43
from openedx.core.djangoapps.user_authn.utils import check_pwned_password
from openedx.core.djangoapps.user_authn.views.registration_form import validate_name, validate_username
from openedx.core.lib.api.view_utils import add_serializer_errors
from common.djangoapps.third_party_auth.utils import get_saml_provider_for_user
from openedx.features.enterprise_support.utils import get_enterprise_readonly_account_fields
from openedx.features.name_affirmation_api.utils import is_name_affirmation_installed
from openedx_filters.learning.filters import AccountSettingsReadOnlyFieldsRequested

from django.test import TestCase
from django.test.client import RequestFactory
from django.urls import reverse
from pytz import UTC
Comment thread lms/envs/common.py
Copilot AI review requested due to automatic review settings May 4, 2026 18:54
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch from 21745b5 to c89d533 Compare May 4, 2026 18:54
Copy link
Copy Markdown

Copilot AI left a comment

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 20 out of 20 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

requirements/edx/base.txt:16

  • The PR description/title focuses on replacing the enterprise_support import with an openedx-filter, but this PR also contains large, broad dependency lockfile updates (e.g., many version bumps in this requirements file and others). Consider either updating the PR description/title to reflect the dependency upgrades or splitting the requirements refresh into a separate PR to keep scope/review risk manageable.
    # via -r requirements/edx/kernel.in
aiohappyeyeballs==2.6.1
    # via aiohttp
aiohttp==3.13.5
    # via geoip2
aiosignal==1.4.0
    # via aiohttp
amqp==5.3.1
    # via kombu

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

Comment thread lms/envs/common.py
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_api.py
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch from c89d533 to 77d4b62 Compare May 4, 2026 20:09
Copilot AI review requested due to automatic review settings May 4, 2026 20:27
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch from 77d4b62 to 747934c Compare May 4, 2026 20:27
Copy link
Copy Markdown

Copilot AI left a comment

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 20 out of 20 changed files in this pull request and generated 3 comments.


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

Comment on lines 195 to 208
def _validate_read_only_fields(user, data, field_errors):
# Check for fields that are not editable. Marking them read-only causes them to be ignored, but we wish to 400.
plugin_readonly_fields, __ = AccountSettingsReadOnlyFieldsRequested.run_filter(
readonly_fields=set(),
user=user,
)
plugin_readonly_fields = plugin_readonly_fields or set()

read_only_fields = set(data.keys()).intersection(
# Remove email since it is handled separately below when checking for changing_email.
(set(AccountUserSerializer.get_read_only_fields()) - {"email"}) |
set(AccountLegacyProfileSerializer.get_read_only_fields() or set()) |
get_enterprise_readonly_account_fields(user)
plugin_readonly_fields
)
Comment thread lms/envs/common.py
Comment thread requirements/edx/base.txt
payload = self._parse_json(payload, "payload")

queue_name = header.get('queue_name', 'default')
queue_key = header.get('lms_key', '')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The PR upgraded edx-submissions 3.12.0 → 4.0.0, which added queue_key as a new required positional parameter to create_external_grader_detail (between queue_name and grader_file_name). The queue_key corresponds to lms_key from the xqueue header (the unique submission tracking key).

def test_get_user_details(self):
""" test get_attr and get_user_details of EdXSAMLIdentityProvider"""
edx_saml_identity_provider = EdXSAMLIdentityProvider('demo', **mock_conf)
edx_saml_identity_provider = EdXSAMLIdentityProvider(mock.Mock(), 'demo', **mock_conf)
Copy link
Copy Markdown
Author

@kiram15 kiram15 May 4, 2026

Choose a reason for hiding this comment

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

Same social-auth-core 4.8.7 upgrade changed SAMLIdentityProvider.init from (self, entity_id, **kwargs) to (self, backend: BaseAuth, name: str, **kwargs).

"""
key = self.conf.get(conf_key, default_attribute)
if key in attributes:
key = self.conf.get(conf_key)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The PR upgraded social-auth-core 4.7.0 → 4.8.7, which changed SAMLIdentityProvider.get_attr from (self, attributes, conf_key, default_attribute) (4 params) to (self, attributes, conf_key, default_attributes: tuple, *, validate_defaults=False) (5 params).

Copilot AI review requested due to automatic review settings May 4, 2026 21:23
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch from e5db97a to de234ce Compare May 4, 2026 21:23
Copy link
Copy Markdown

Copilot AI left a comment

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 23 out of 23 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

requirements/edx/base.txt:15

  • The PR description focuses on switching the enterprise read-only fields logic to an openedx-filters hook, but this PR also includes a broad set of dependency upgrades/pins and unrelated functional changes (e.g., SAML and xqueue submission behavior). Consider splitting these into separate PRs (or expand the PR description) so reviewers can assess risk and rollout implications more clearly.
acid-xblock==0.4.1
    # via -r requirements/edx/kernel.in
aiohappyeyeballs==2.6.1
    # via aiohttp
aiohttp==3.13.5
    # via geoip2
aiosignal==1.4.0
    # via aiohttp
amqp==5.3.1

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

Comment on lines 52 to 105
@@ -83,21 +84,22 @@ def get_submission_params(self, header, payload):
'student_id': student_id
}

return student_dict, student_answer, queue_name, grader_file_name, points_possible
return student_dict, student_answer, queue_name, queue_key, grader_file_name, points_possible

def send_to_submission(self, header, body, files_to_upload=None):
"""
Submits the extracted student data to the edx-submissions system.
"""
try:
from submissions.api import create_external_grader_detail
student_item, answer, queue_name, grader_file_name, points_possible = (
student_item, answer, queue_name, queue_key, grader_file_name, points_possible = (
self.get_submission_params(header, body)
)
return create_external_grader_detail(
student_item,
answer,
queue_name=queue_name,
queue_key=queue_key,
grader_file_name=grader_file_name,
points_possible=points_possible,
files=files_to_upload
Comment on lines 293 to 296
Get the attribute 'default_attribute' out of the attributes,
unless self.conf[conf_key] overrides the default by specifying
another attribute to use.
"""
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch 2 times, most recently from 215af2e to 75c1d02 Compare May 4, 2026 22:00
Copilot AI review requested due to automatic review settings May 4, 2026 22:00
Copy link
Copy Markdown

Copilot AI left a comment

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 26 out of 26 changed files in this pull request and generated 3 comments.


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

Comment on lines 52 to 55
queue_name = header.get('queue_name', 'default')
queue_key = header.get('lms_key', '')

if not self.block:
Comment on lines +141 to +144
# Pin astroid to 4.0.4 for compatibility with sphinx-autoapi and pylint under Python 3.11
# sphinx-autoapi<3.6.1 is incompatible with astroid>=4.1.2, so we pin astroid to 4.0.x series
# to ensure all dependencies can resolve properly.
# Remove this constraint once we migrate to Python 3.12.
Comment thread common/djangoapps/third_party_auth/saml.py
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch from 75c1d02 to 267ca0c Compare May 4, 2026 22:35
Copilot AI review requested due to automatic review settings May 4, 2026 22:40
@kiram15 kiram15 force-pushed the kiram15/ENT-11510 branch from 267ca0c to 8ef0c30 Compare May 4, 2026 22:40
Copy link
Copy Markdown

Copilot AI left a comment

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 26 out of 26 changed files in this pull request and generated 2 comments.


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

Comment thread requirements/edx/base.txt
Comment on lines 7 to 12
acid-xblock==0.4.1
# via -r requirements/edx/kernel.in
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.13.3
aiohttp==3.13.5
# via geoip2
Comment thread mypy.ini
Comment on lines +73 to +74
[mypy-requests.*]
ignore_missing_imports = True
@kiram15 kiram15 closed this May 5, 2026
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.

3 participants