openedx / xblock-lti-consumer

GNU Affero General Public License v3.0
28 stars 80 forks source link

XBlock rendering breaks when using an non-existent external configuration #420

Open Agrendalath opened 10 months ago

Agrendalath commented 10 months ago

Steps to reproduce

  1. Go to Studio and create a new LTI Consumer XBlock.
  2. Set the Configuration Type to Reusable Configuration.
  3. Provide a random LTI Reusable Configuration ID.

What happens

The XBlock break with Error: (1048, "Column 'version' cannot be null"). The relevant part of the traceback is:

File "/edx/shared-src/xblock-lti-consumer/lti_consumer/lti_xblock.py", line 1177, in author_view
  return self.student_view(context)
File "/edx/shared-src/xblock-lti-consumer/lti_consumer/lti_xblock.py", line 1227, in student_view
  context.update(self._get_context_for_template())
File "/edx/shared-src/xblock-lti-consumer/lti_consumer/lti_xblock.py", line 1730, in _get_context_for_template
  lti_consumer = self._get_lti_consumer()
File "/edx/shared-src/xblock-lti-consumer/lti_consumer/lti_xblock.py", line 1128, in _get_lti_consumer
  return get_lti_consumer(config_id_for_block(self))
File "/edx/shared-src/xblock-lti-consumer/lti_consumer/api.py", line 96, in config_id_for_block
  config = _get_lti_config_for_block(block)
File "/edx/shared-src/xblock-lti-consumer/lti_consumer/api.py", line 76, in _get_lti_config_for_block
  lti_config = _get_or_create_local_lti_config(
File "/edx/shared-src/xblock-lti-consumer/lti_consumer/api.py", line 46, in _get_or_create_local_lti_config
  lti_config.save()
File "/edx/shared-src/xblock-lti-consumer/lti_consumer/models.py", line 313, in save
  super().save(*args, **kwargs)

What should happen?

The XBlock should display an error about an invalid external configuration ID.

Note: Ensure that students (i.e., users without staff permissions) cannot see this error in LMS.

_Originally posted by @Agrendalath in https://github.com/openedx/xblock-lti-consumer/pull/390#discussion_r1342736479_

kuipumu commented 10 months ago

@Agrendalath I created a PR for a possible fix for this issue: https://github.com/openedx/xblock-lti-consumer/pull/423

Agrendalath commented 10 months ago

Thanks, @kuipumu! I won't be able to test it this week, but I can do this in the next one.