ADL_LRS
ADL_LRS copied to clipboard
SuspiciousFileOperation: Storage can not find an available filename for "activity_state/
I am having an issue with Storyline begin unable to perform a PUT to the State API. I get an HTTP 500 error. See the excerpt from the lrs.log file (below)
It mentions Please make sure that the corresponding file field allows sufficient "max_length".
Will changing "max_length" solve the issue? (If so, how do I do that?)
2019-12-08 19:05:49,302 [ERROR] lrs.views: 500 === /XAPI/activities/state Traceback (most recent call last): File "./lrs/views.py", line 214, in handle_request return processors[path]req_dict['method'] File "./lrs/utils/req_process.py", line 292, in activity_state_put actstate.put_state(req_dict) File "./lrs/managers/ActivityStateManager.py", line 119, in put_state self.save_non_json_state(s, post_state, request_dict) File "./lrs/managers/ActivityStateManager.py", line 30, in save_non_json_state s.state.save(fn, state) File "/home/ubuntu/env/local/lib/python2.7/site-packages/django/db/models/fields/files.py", line 94, in save self.name = self.storage.save(name, content, max_length=self.field.max_length) File "/home/ubuntu/env/local/lib/python2.7/site-packages/django/core/files/storage.py", line 53, in save name = self.get_available_name(name, max_length=max_length) File "/home/ubuntu/env/local/lib/python2.7/site-packages/django/core/files/storage.py", line 91, in get_available_name 'allows sufficient "max_length".' % name SuspiciousFileOperation: Storage can not find an available filename for "activity_state/133_https:/d23h0z1ueo5mz5.cloudfront.net/Pesticide+Seller+eLearning+Course_15/story_html5_vxl3WPb.html_21". Please make sure that the corresponding file field allows sufficient "max_length".
Morning Bill, I haven't seen this one before. Is this coming from the public ADL LRS instance or one you're hosting?
Looking around, it seems that the default filename length is 100 characters for Django models (the framework used by this LRS). That can be extended (as the name in your example is 120 characters), so the easiest way would be to modify your state model to include that updated size:
https://github.com/adlnet/ADL_LRS/blob/master/lrs/models.py#L696
Namely:
state = models.FileField(upload_to=ACTIVITY_STATE_UPLOAD_TO, null=True)
to something like
state = models.FileField(upload_to=ACTIVITY_STATE_UPLOAD_TO, null=True, max_length=500)