-
Notifications
You must be signed in to change notification settings - Fork 60
Don't cause a 500 error in the LMS if get_block unexpectedly returns None #54
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
Conversation
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.
Nit: If this fails, the new version gives a rather unspecific error message ("expected True, but found False", or something like that). I suggest adding a message like "expected link ending in {link_href} but found {href}" (though we could also do that if the test ever fails, which might be never).
|
👍 The code and the test look good, and I only had minor comments on the unrelated test fix. I can't really test this fix, since I can't reproduce the original error locally (at least not with reasonable effort), but the code change looks safe, and the test covers the newly added code path. |
0765e21 to
6d98263
Compare
|
Thanks @smarnach. I amended the second commit to address your comments. |
|
@cpennington Could you please review this? It's a little fix to Problem Builder to avoid the 500 error we've been looking at in https://openedx.atlassian.net/browse/PLAT-772 . |
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.
If it's a permission issue, then is it correct to call it 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.
Good point, but since there's no mechanism for setting permissions on child blocks at the moment, I think it would indicate an error, at least with the current runtime.
BTW, does the API explicitly state whether the "children" property may include blocks that the user doesn't have permission to access?
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.
Also, in this case, if permissions are the problem, I would consider it a "configuration error" - the block is not designed to handle variable children, so if an author has configured it that way, they're using it incorrectly. Thankfully though that shouldn't be an issue in theory since there is no mechanism to do that AFAIK.
|
👍 |
Don't cause a 500 error in the LMS if get_block unexpectedly returns None
Description: We ran into a weird issue in a live course, where
get_blockreturnedNonein the following code:Since we didn't expect
childever to beNonewith that API, this resulted inAttributeError: 'NoneType' object has no attribute 'render', causing the whole subsection of the LMS to be replaced with a 500 error.Although
get_blockshouldn't returnNoneif everything is working, it is an expected return value when an error occurs, so we should be able to handle it gracefully.I added an error message to the rendered HTML so that there will at least be some indication that content is missing - otherwise this could result in content silently disappearing for students even though instructors can see it fine :-/
Merge deadline: ASAP, targeting this week's release
Reviewers: @smarnach
attn: @antoviaque