feat: replace enterprise_support import with AccountSettingsReadOnlyF…#201
feat: replace enterprise_support import with AccountSettingsReadOnlyF…#201kiram15 wants to merge 5 commits intorelease-ulmofrom
Conversation
There was a problem hiding this comment.
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_filterin the accounts API. - Update/adjust unit tests for the new filter-based behavior and swap UTC handling to
zoneinfo. - Bump
edx-enterpriseto6.8.2and introduce/update settings intended to configureOPEN_EDX_FILTERS_CONFIGand 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.
…ieldsRequested filter
7daf9c6 to
a7a5a6f
Compare
There was a problem hiding this comment.
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.
| plugin_readonly_fields, __ = AccountSettingsReadOnlyFieldsRequested.run_filter( | ||
| readonly_fields=set(), | ||
| user=user, | ||
| ) |
There was a problem hiding this comment.
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).
| # 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(): |
There was a problem hiding this comment.
_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.
| 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(): |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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 | ||
| ) |
| payload = self._parse_json(payload, "payload") | ||
|
|
||
| queue_name = header.get('queue_name', 'default') | ||
| queue_key = header.get('lms_key', '') |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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-filtershook, 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.
| @@ -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 | |||
| Get the attribute 'default_attribute' out of the attributes, | ||
| unless self.conf[conf_key] overrides the default by specifying | ||
| another attribute to use. | ||
| """ |
215af2e to
75c1d02
Compare
There was a problem hiding this comment.
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.
| queue_name = header.get('queue_name', 'default') | ||
| queue_key = header.get('lms_key', '') | ||
|
|
||
| if not self.block: |
| # 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. |
There was a problem hiding this comment.
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.
| 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 |
| [mypy-requests.*] | ||
| ignore_missing_imports = True |
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:
"Developer", and "Operator".
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.