-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: wrap into try/except block getting icon for xblock #2509
Conversation
xmodule/split_test_block.py
Outdated
return self.runtime.get_block_for_descriptor(self.child_block) | ||
else: | ||
except (NoSuchServiceError, AttributeError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except (NoSuchServiceError, AttributeError): | |
except (NoSuchServiceError, AttributeError): | |
logging.warning("Error fetching child block: %s", e) |
can we add some logging here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this try except is for?
self.child_block
or self.runtime.get_block_for_descriptor
if for self.child_block
I would enclose in try/except only self.child_block
, and keep self.runtime.get_block_for_descriptor
outside of the try/except
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe even put try/except in the def child_block
property if possible
14403d3
to
7df6d68
Compare
7df6d68
to
edc5739
Compare
edc5739
to
0557c26
Compare
@GlugovGrGlib @monteri added logging and divided try/except block by error location. |
xmodule/split_test_block.py
Outdated
return self.runtime.get_block_for_descriptor(self.child_block) | ||
else: | ||
except AttributeError: | ||
log.warning("Error while getting block for descriptor") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unique identifier (e.g. location), so it's possible to debug an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also can't understand why you removed if self.child_block is not None
it means that you may break a case when child_block
is None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Location added to both logs
xmodule/split_test_block.py
Outdated
try: | ||
group_id = self.get_group_id() | ||
except NoSuchServiceError: | ||
log.warning("Error while getting user service in runtime") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unique identifier as in previous logging
xmodule/split_test_block.py
Outdated
@@ -172,10 +173,14 @@ def child_block(self): | |||
def child(self): | |||
""" | |||
Return the user bound child block for the partition or None. | |||
|
|||
We are using try/except block here because we ran into issues with | |||
CachingDescriptorSystem has no attribute when we get an icon for the split_test xblock. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should be changed specifying the technical issue
and note just - we get an icon for the split_test xblock
e.g.
Handles the AttributeError
exception that may occur when attempting to retrieve the split_test
xBlock information within the CMS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstrings were changed
xmodule/split_test_block.py
Outdated
@@ -212,8 +217,16 @@ def get_content_titles(self): | |||
def get_child_blocks(self): | |||
""" | |||
For grading--return just the chosen child. | |||
|
|||
We are using try/except block here because we ran into issues with | |||
User service being undefined when we get an icon for the split_test xblock. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update docstring as in the previous function
e7353b1
to
f90846b
Compare
f90846b
to
98b5d33
Compare
98b5d33
to
c42d7dd
Compare
* fix: wrap into try/except block getting icon for xblock * fix: revision after review
* feat: XBlock's children API as DRF * fix: 500 error appears if user adds a Content Experiment * fix: wrap into try/except block getting icon for xblock (#2509) * fix: wrap into try/except block getting icon for xblock * fix: revision after review
Related upstream issue: openedx#34055
Results:
When trying to display a unit which contains two
split_test
block's (the former without group applied the latter with applied group) we getother
icon typeWhen trying to display a unit which contains video and
split_test
block we getvideo
icon type