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

Direct File upload gives 500: Internal Server Error #77

Open
MyuddinKhatri opened this issue Aug 2, 2024 · 1 comment
Open

Direct File upload gives 500: Internal Server Error #77

MyuddinKhatri opened this issue Aug 2, 2024 · 1 comment
Assignees

Comments

@MyuddinKhatri
Copy link
Collaborator

Is user directly tries to upload the File without being attached to any doctype, then it gives error Stack Trace -

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 97, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 48, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1619, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/handler.py", line 229, in upload_file
    return frappe.get_doc(
  File "apps/frappe/frappe/model/document.py", line 310, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 332, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 259, in insert
    self.run_method("before_insert")
  File "apps/frappe/frappe/model/document.py", line 931, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1283, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1265, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 928, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/core/doctype/file/file.py", line 72, in before_insert
    self.save_file(content=self.get_content())
  File "apps/frappe/frappe/core/doctype/file/file.py", line 604, in save_file
    return write_file_method(self)
  File "apps/cloud_storage/cloud_storage/cloud_storage/overrides/file.py", line 490, in write_file
    return upload_file(file)
  File "apps/cloud_storage/cloud_storage/cloud_storage/overrides/file.py", line 407, in upload_file
    path = get_file_path(file, client.folder)
  File "apps/cloud_storage/cloud_storage/cloud_storage/overrides/file.py", line 430, in get_file_path
    file.attached_to_name.replace("#", "%23"),
AttributeError: 'NoneType' object has no attribute 'replace'

As the file is not attached to document and it tries to do file.attached_to_name.replace("#", "%23")

@Alchez
Copy link
Collaborator

Alchez commented Aug 2, 2024

@MyuddinKhatri this should be an easy enough fix. Let's just check if the file is attached, and only then replace the string. Check for other instances of this as well.

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