agritheory / cloud_storage

S3 protocol storage for Frappe Applications - compatible with S3, Backblaze and DO Spaces
https://agritheory.com/documentation/cloud_storage
Other
12 stars 7 forks source link

permissions configuration missing #75

Open rparsimony opened 2 months ago

rparsimony commented 2 months ago

Hello, You mention the permissions and state that they are in the configuration.md doc, but there are no permissions there.

agritheory commented 2 months ago

@rparsimony What kind of permissions are you referring to? User-facing permissions or object storage credentials?

rparsimony commented 2 months ago

@agritheory

Object storage permissions. In the production.md doc on step 5.

agritheory commented 2 months ago

I see it here: https://github.com/agritheory/cloud_storage/blob/version-15/docs/configuration.md

rparsimony commented 2 months ago

Unless I'm blind, and I'm not ruling this out just yet, the configuration file exists but I'm not seeing any permissions related to AWS in that file, or the aws setup file. The only thing in that doc is the settings for the site_config.json file. The main reason I'm asking about it is I'm trying to use this plugin and I'm getting a 500 error.

image

The only error I'm getting from erpnext is when I try to upload a file that is already present I get this: OSError: File does not exist from: File /bench/apps/cloud_storage/cloud_storage/cloud_storage/overrides/file.py", line 106, in validate super().validate()

But with a new file it's still a 500 error but no validation.

agritheory commented 2 months ago

@rparsimony Can you provide a stack trace from the browser console? A 500 error is not permissions related, those are various 400 status codes.

rparsimony commented 2 months ago

This is a stack trace from the browser console:

GET
<url of another file in the same document>
NS_ERROR_FAILURE

set innerHTML
moz-extension://42ac83b8-f509-408a-8fe2-414c1de9cd10/lib/iframeProtection.js:153:26
createProxyFunction/handler.apply<
moz-extension://42ac83b8-f509-408a-8fe2-414c1de9cd10/lib/extension.js:208:18
p1</</html/<
jquery.js:6333:7
ve
jquery.js:4171:7
html
jquery.js:6311:9
update_preview
html_editor.js:13:24
set_formatted_input/<
markdown_editor.js:55:8
(Async: promise callback) set_formatted_input
markdown_editor.js:54:35
set_input
data.js:247:7
n
base_input.js:80:7
refresh_input
base_input.js:101:4
refresh
base_control.js:145:8
attach_doc_and_docfields
layout.js:440:58
refresh
layout.js:317:7
refresh_fields
form.js:655:14
render_form/<
form.js:607:15
(Async: promise callback) frappe.run_serially/<
dom.js:262:33
frappe.run_serially
dom.js:260:7
render_form
form.js:599:10
trigger_onload
form.js:552:8
refresh
form.js:430:8
l
form.js:773:7
callback
save.js:28:5
callback
save.js:252:26
e
request.js:85:15
200
request.js:128:33
frappe.request.call/<
request.js:294:5
V
jquery.js:3500:30
fireWith
jquery.js:3630:6
S0
jquery.js:9796:13
p1</</</send/f/<
jquery.js:10057:8
r
helpers.ts:98
(Async: EventHandlerNonNull) L
object.ts:39
Vc/</<
trycatch.ts:155
Vc/<
trycatch.ts:152
Sa/</<
instrument.ts:286
send
jquery.js:10109:9
ajax
jquery.js:9690:14
frappe.request.call
request.js:268:10
frappe.call
request.js:105:23
h
save.js:245:16
n
save.js:23:3
frappe.ui.form.save
save.js:272:2
validate_and_save/<
form.js:808:21
(Async: promise callback) frappe.run_serially/<
dom.js:262:33
frappe.run_serially
dom.js:260:7
validate_and_save
form.js:799:5
save/<
form.js:738:6
save
form.js:735:9
on_upload_complete
attach.js:124:68
on_success
attach.js:73:9
upload_file/</g.onreadystatechange
FileUploader.vue:590:13
Sa/</</</<
instrument.ts:263
(Async: EventHandlerNonNull) L
object.ts:39
Vc/</<
trycatch.ts:155
Vc/<
trycatch.ts:152
Sa/</<
instrument.ts:286

Here is the python stack trace:

Form Dict: {'is_private': '1', 'folder': 'Home/test', 'cmd': 'upload_file'}
Traceback (most recent call last):
  File "/home/<user>/bench/apps/frappe/frappe/app.py", line 95, in application
    response = frappe.api.handle()
  File "/home/<user>/bench/apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "/home/<user>/bench/apps/frappe/frappe/handler.py", line 47, in handle
    data = execute_cmd(cmd)
  File "/home/<user>/bench/apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/<user>/bench/apps/frappe/frappe/__init__.py", line 1622, in call
    return fn(*args, **newargs)
  File "/home/<user>/bench/apps/frappe/frappe/handler.py", line 223, in upload_file
    return frappe.get_doc(
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 307, in save
    return self._save(*args, **kwargs)
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 329, in _save
    return self.insert()
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 261, in insert
    self.run_before_save_methods()
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 1053, in run_before_save_methods
    self.run_method("validate")
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 917, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 1279, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 1261, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/<user>/bench/apps/frappe/frappe/model/document.py", line 914, in fn
    return method_object(*args, **kwargs)
  File "/home/<user>/bench/apps/cloud_storage/cloud_storage/cloud_storage/overrides/file.py", line 106, in validate
    super().validate()
  File "/home/<user>/bench/apps/frappe/frappe/core/doctype/file/file.py", line 99, in validate
    self.validate_file_on_disk()
  File "/home/<user>/bench/apps/frappe/frappe/__init__.py", line 534, in throw
    msgprint(
  File "/home/<user>/bench/apps/frappe/frappe/__init__.py", line 502, in msgprint
    _raise_exception()
  File "/home/<user>/bench/apps/frappe/frappe/__init__.py", line 451, in _raise_exception
    raise raise_exception(msg)
OSError: File  does not exist
agritheory commented 2 months ago

You can screenshot the the version you're using from the UI: Help -> About

rparsimony commented 2 months ago

The python stack trace is what shows up when I try to upload a file that already exists in the S3 bucket. I don't get a stack trace for a new upload.

If I try and add a file as an attachment rather than just a plain upload I get the 500 error, the browser console stack track above for another attachment in the same document.

rparsimony commented 2 months ago

You can screenshot the the version you're using from the UI: Help -> About

This is for a site with version 14 of erpnext/frappe and such. image

MyuddinKhatri commented 2 months ago

@rparsimony the PR is merged, can you please update your app and test this again?

rparsimony commented 2 months ago

@rparsimony the PR is merged, can you please update your app and test this again?

I tested this fix and it does fix the main issue. Files upload properly now. But there is some weirdness when attaching a file to a doctype, such as with a Letter Head. The document doesn't attach properly/pass the proper link to the attachment point. A work around is to upload the file normally and then take the link generated in the file and put that as a "Link" attachment from the Letter Head.