Skip to content
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

SuspiciousFileOperation: Storage can not find an available filename for "activity_state/ #487

Open
MrBillMcDonald opened this issue Dec 9, 2019 · 2 comments

Comments

@MrBillMcDonald
Copy link

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".

@adl-trey
Copy link
Contributor

adl-trey commented Dec 9, 2019

Morning Bill, I haven't seen this one before. Is this coming from the public ADL LRS instance or one you're hosting?

@adl-trey
Copy link
Contributor

adl-trey commented Dec 9, 2019

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants