dfp_external_storage icon indicating copy to clipboard operation
dfp_external_storage copied to clipboard

Error generating Prepared Report

Open MrJico opened this issue 1 year ago • 0 comments

while generating prepared reports, the file is neither handled be the internal file system, and not by drf it self, hence the error

this error was triggered by Stock Balance

Full Traceback

Traceback with variables (most recent call last):
  File "apps/frappe/frappe/core/doctype/prepared_report/prepared_report.py", line 113, in generate_report
    create_json_gz_file(result, instance.doctype, instance.name, instance.report_name)
      prepared_report = 'tflee3682v'
      instance = <PreparedReport: tflee3682v>
      report = <Report: Stock Balance>
      result = {'result': [{'item_code': '1648', 'warehouse': 'Erbil - SDS', 'item_group': 'Other', 'company': 'Al-Sharaa Dental Solutions', 'currency': 0.0, 'stock_uom': 'Unit', 'item_name': 'Micromotor engine handpiece', 'opening_qty': 2.0, 'opening_val': 2.0, 'opening_fifo_queue': [], 'in_qty': 0.0, 'in_val': 0.0, 'out_qty': 0.0, 'out_val': 0.0, 'bal_qty': 2.0, 'bal_val': 2.0, 'val_rate': 1.0, 'reserved_stock': 0.0}, {'item_code': '808', 'warehouse': 'Erbil - SDS', 'item_group': 'Lazon', 'company': 'Al-Sharaa Dental Solutions', 'currency': 0.0, 'stock_uom': 'Unit', 'item_name': 'Solase fiber tip 400', 'opening_qty': 689.0, 'opening_val': 1791.4, 'opening_fifo_queue': [], 'in_qty': 0.0, 'in_val': 0.0, 'out_qty': 0.0, 'out_val': 0.0, 'bal_qty': 689.0, 'bal_val': 1791.4, 'val_rate': 2.6, 'reserved_stock': 0.0}, {'item_code': '1605', 'warehouse': 'Erbil - SDS', 'item_group': 'Other', 'company': 'Al-Sharaa Dental Solutions', 'currency': 0.0, 'stock_uom': 'Unit', 'item_name': 'Chairman Diamond coated bu...
  File "apps/frappe/frappe/core/doctype/prepared_report/prepared_report.py", line 245, in create_json_gz_file
    _file.save(ignore_permissions=True)
      data = {'result': [{'item_code': '1648', 'warehouse': 'Erbil - SDS', 'item_group': 'Other', 'company': 'Al-Sharaa Dental Solutions', 'currency': 0.0, 'stock_uom': 'Unit', 'item_name': 'Micromotor engine handpiece', 'opening_qty': 2.0, 'opening_val': 2.0, 'opening_fifo_queue': [], 'in_qty': 0.0, 'in_val': 0.0, 'out_qty': 0.0, 'out_val': 0.0, 'bal_qty': 2.0, 'bal_val': 2.0, 'val_rate': 1.0, 'reserved_stock': 0.0}, {'item_code': '808', 'warehouse': 'Erbil - SDS', 'item_group': 'Lazon', 'company': 'Al-Sharaa Dental Solutions', 'currency': 0.0, 'stock_uom': 'Unit', 'item_name': 'Solase fiber tip 400', 'opening_qty': 689.0, 'opening_val': 1791.4, 'opening_fifo_queue': [], 'in_qty': 0.0, 'in_val': 0.0, 'out_qty': 0.0, 'out_val': 0.0, 'bal_qty': 689.0, 'bal_val': 1791.4, 'val_rate': 2.6, 'reserved_stock': 0.0}, {'item_code': '1605', 'warehouse': 'Erbil - SDS', 'item_group': 'Other', 'company': 'Al-Sharaa Dental Solutions', 'currency': 0.0, 'stock_uom': 'Unit', 'item_name': 'Chairman Diamond coated bu...
      dt = 'Prepared Report'
      dn = 'tflee3682v'
      report_name = 'Stock Balance'
      json_filename = 'stock_balance_2024-8-20-12-5.json.gz'
      encoded_content = b'{"chart":null,"columns":[{"fieldname":"item_code","fieldtype":"Link","label":"Item","options":"Item","width":100},{"fieldname":"item_name","label":"Item Name","width":150},{"fieldname":"item_group","fieldtype":"Link","label":"Item Group","options":"Item Group","width":100},{"fieldname":"warehouse","fieldtype":"Link","label":"Warehouse","options":"Warehouse","width":100},{"fieldname":"stock_uom","fieldtype":"Link","label":"Stock UOM","options":"UOM","width":90},{"convertible":"qty","fieldname":"bal_qty","fieldtype":"Float","label":"Balance Qty","width":100},{"fieldname":"bal_val","fieldtype":"Currency","label":"Balance Value","options":"Company:company:default_currency","width":100},{"convertible":"qty","fieldname":"opening_qty","fieldtype":"Float","label":"Opening Qty","width":100},{"fieldname":"opening_val","fieldtype":"Currency","label":"Opening Value","options":"Company:company:default_currency","width":110},{"convertible":"qty","fieldname":"in_qty","fieldtype":"Float","label":"In...
      compressed_content = b'\x1f\x8b\x08\x00\x12\x13Kf\x02\xff\xed]\xfbs\xdb8\x92\xfeWP\xae\xda\xabd\xd7\xd6\x12\x00\xc1G~\xb9\x8a\x1f\x99\xe4\xc6\x1e\xfb\xeclfn\x1e\x95\xa2(\xd8\xe6\x9a"\xb9|\xc4r\xb6\xf6\x7f?\x80\xa4l\xf1\x91\x04 \tX\xf6dj\xca\xb1(\x19T\x7fh6\x1a\x8d\xee\xfe\xfe\xbd\xe3_{i\xbe\xf3**\xc2pw\xc7\x8f\xc3b\x19e;\xaf~\xfb\xf7\xcee@\xc3E\xe4-\xe9\xce\xab\x9d \xa7\xcb\x8f~\xbc\xa0;\xbb\xd5\xf5\xfc.\xe1\xd7\x8f\x83\xe8\x86]\n\xbd9\r\xd9\xcbw\xecc\xece\x9c\xe4A\xccGY_\xb8\r\x16\xf9\xf5\xce+h\x18\xff\xd9\xed\x19\xb8\xfc\xbd9\n\xf8\xa9\xba\xb6\xfeK\xd2\xff\x97Wi\\$\xdf\xfeN\xe0\x87\xfas\xcdov\x7f\xf9\xcb\xdf\xef\xd6K\xe9u\\d\xdf\x10\xfc\xe7\x8d\x8f=\xdcc\xf3\xea\x97o\x91\xe5\xb1\x7f\xf3\xb1\x88\x97_\xbf\xc5\x05\xff\x18\xf8\xc7\xe9I\xe3\x16\xd5\xebzp\xb7\x1c\xdb\x8f\xa3O4\xcd\x83y\xc8G\xf9W~\xb7\x1e\xb7\xbe\xdf\xdc\x0b?n\\\xad\xef\xf6&\x8c\xbd|\xe3v\xfb^\xe8E>\x05\xff[~\xf2\xcb\xdf\x9e\x8f\xf6\xc9\x0b[\xa3\x1d\x14iJ#\xff\xaeg\xc0\x0f^X4a:\x88\x97\x89\x17\xdd\xbd\xf2\xeb\x7f\x17\xf4\xd2+\xc2\xfc\xa3\xff0H\...
      _file = <DFPExternalStorageFile: 53ca41659f>
  File "apps/frappe/frappe/model/document.py", line 337, in save
    return self._save(*args, **kwargs)
      self = <DFPExternalStorageFile: 53ca41659f>
      args = ()
      kwargs = {'ignore_permissions': True}
  File "apps/frappe/frappe/model/document.py", line 359, in _save
    return self.insert()
      self = <DFPExternalStorageFile: 53ca41659f>
      ignore_permissions = True
      ignore_version = None
  File "apps/frappe/frappe/model/document.py", line 291, in insert
    self.run_before_save_methods()
      self = <DFPExternalStorageFile: 53ca41659f>
      ignore_permissions = None
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
  File "apps/frappe/frappe/model/document.py", line 1092, in run_before_save_methods
    self.run_method("before_save")
      self = <DFPExternalStorageFile: 53ca41659f>
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <DFPExternalStorageFile: 53ca41659f>
      args = ()
      kwargs = {}
      fn = <function Document.run_method.<locals>.fn at 0x7f3f074ce680>
      method = 'before_save'
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
      self = <DFPExternalStorageFile: 53ca41659f>
      args = ()
      kwargs = {}
      hooks = [<function hook_file_before_save at 0x7f3f074cea70>]
      method = 'before_save'
      doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions'], 'on_update_after_submit': ['frappe.workflow.doctype.workflow_action.workflow_action.process_w...
      handler = 'dfp_external_storage.dfp_external_storage.doctype.dfp_external_storage.dfp_external_storage.hook_file_before_save'
      composed = <function Document.hook.<locals>.compose.<locals>.runner at 0x7f3efff11360>
      compose = <function Document.hook.<locals>.compose at 0x7f3efff11240>
      f = <function Document.run_method.<locals>.fn at 0x7f3f074ce680>
  File "apps/frappe/frappe/model/document.py", line 1306, in runner
    add_to_return_value(self, f(self, method, *args, **kwargs))
      self = <DFPExternalStorageFile: 53ca41659f>
      method = 'before_save'
      args = ()
      kwargs = {}
      f = <function hook_file_before_save at 0x7f3f074cea70>
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x7f3efff11510>
      fn = <function Document.run_method.<locals>.fn at 0x7f3f074ce680>
      hooks = (<function hook_file_before_save at 0x7f3f074cea70>,)
  File "apps/dfp_external_storage/dfp_external_storage/dfp_external_storage/doctype/dfp_external_storage/dfp_external_storage.py", line 598, in hook_file_before_save
    doc.dfp_external_storage_upload_file()
      doc = <DFPExternalStorageFile: 53ca41659f>
      method = 'before_save'
      previous = None
  File "apps/dfp_external_storage/dfp_external_storage/dfp_external_storage/doctype/dfp_external_storage/dfp_external_storage.py", line 412, in dfp_external_storage_upload_file
    frappe.log_error(f"{error_msg} {error_extra}: {self.file_name}")
      self = <DFPExternalStorageFile: 53ca41659f>
      local_file = './demoerp.alsharaa-dent.com/private/files/stock_balance_2024-8-20-12-5.json.gz'
      original_file_url = '/private/files/stock_balance_2024-8-20-12-5.json.gz'
      base = 'stock_balance_2024-8-20-12-5.json'
      extension = '.gz'
      key = ********
      is_public = ''
      f = <_io.BufferedReader name='./demoerp.alsharaa-dent.com/private/files/stock_balance_2024-8-20-12-5.json.gz'>
      error_msg = "Error saving file in remote folder: 'NoneType' object has no attribute 'put_object'"
      error_extra = 'File saved in local filesystem.'
  File "apps/frappe/frappe/utils/error.py", line 76, in log_error
    return error_log.insert(ignore_permissions=True)
      title = "Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz"
      message = None
      reference_doctype = None
      reference_name = None
      defer_insert = False
      get_trace_id = <function get_trace_id at 0x7f3f06fe3910>
      capture_exception = <function capture_exception at 0x7f3effe116c0>
      traceback = 'Traceback with variables (most recent call last):\n  File "apps/dfp_external_storage/dfp_external_storage/dfp_external_storage/doctype/dfp_external_storage/dfp_external_storage.py", line 393, in dfp_external_storage_upload_file\n    self.dfp_external_storage_client.put_object(\n      self = <DFPExternalStorageFile: 53ca41659f>\n      local_file = \'./demoerp.alsharaa-dent.com/private/files/stock_balance_2024-8-20-12-5.json.gz\'\n      original_file_url = \'/private/files/stock_balance_2024-8-20-12-5.json.gz\'\n      base = \'stock_balance_2024-8-20-12-5.json\'\n      extension = \'.gz\'\n      key = ********\n      is_public = \'\'\n      f = <_io.BufferedReader name=\'./demoerp.alsharaa-dent.com/private/files/stock_balance_2024-8-20-12-5.json.gz\'>\n      e = AttributeError("\'NoneType\' object has no attribute \'put_object\'")\n      error_msg = "Error saving file in remote folder: \'NoneType\' object has no attribute \'put_object\'"\n      error_extra = \'File saved in local filesy...
      trace_id = None
      error_log = <ErrorLog: tflpeqcsfo>
  File "apps/frappe/frappe/model/document.py", line 292, in insert
    self._validate()
      self = <ErrorLog: tflpeqcsfo>
      ignore_permissions = True
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
  File "apps/frappe/frappe/model/document.py", line 578, in _validate
    self._validate_length()
      self = <ErrorLog: tflpeqcsfo>
  File "apps/frappe/frappe/model/base_document.py", line 969, in _validate_length
    self.throw_length_exceeded_error(df, max_length, value)
      self = <ErrorLog: tflpeqcsfo>
      type_map = {'Currency': ('decimal', '21,9'), 'Int': ('int', '11'), 'Long Int': ('bigint', '20'), 'Float': ('decimal', '21,9'), 'Percent': ('decimal', '21,9'), 'Check': ('int', '1'), 'Small Text': ('text', ''), 'Long Text': ('longtext', ''), 'Code': ('longtext', ''), 'Text Editor': ('longtext', ''), 'Markdown Editor': ('longtext', ''), 'HTML Editor': ('longtext', ''), 'Date': ('date', ''), 'Datetime': ('datetime', '6'), 'Time': ('time', '6'), 'Text': ('text', ''), 'Data': ('varchar', 140), 'Link': ('varchar', 140), 'Dynamic Link': ('varchar', 140), 'Password': ('text', ''), 'Select': ('varchar', 140), 'Rating': ('decimal', '3,2'), 'Read Only': ('varchar', 140), 'Attach': ('text', ''), 'Attach Image': ('text', ''), 'Signature': ('longtext', ''), 'Color': ('varchar', 140), 'Barcode': ('longtext', ''), 'Geolocation': ('longtext', ''), 'Duration': ('decimal', '21,9'), 'Icon': ('varchar', 140), 'Phone': ('varchar', 140), 'Autocomplete': ('varchar', 140), 'JSON': ('json', '')}
      fieldname = 'method'
      value = "Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz"
      df = <DataDocField: method parent=Error Log>
      column_type = 'varchar'
      default_column_max_length = 140
      max_length = 140
  File "apps/frappe/frappe/model/base_document.py", line 1006, in throw_length_exceeded_error
    frappe.throw(
      self = <ErrorLog: tflpeqcsfo>
      df = <DataDocField: method parent=Error Log>
      max_length = 140
      value = "Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz"
      reference = 'Error Log tflpeqcsfo'
  File "apps/frappe/frappe/__init__.py", line 645, in throw
    msgprint(
      msg = "Error Log tflpeqcsfo: 'Title' (Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz) will get truncated, as max characters allowed is 140"
      exc = <class 'frappe.exceptions.CharacterLengthExceededError'>
      title = 'Value too big'
      is_minimizable = False
      wide = False
      as_list = False
      primary_action = None
  File "apps/frappe/frappe/__init__.py", line 610, in msgprint
    _raise_exception()
      title = 'Value too big'
      as_table = False
      as_list = False
      indicator = 'red'
      alert = False
      primary_action = None
      is_minimizable = False
      wide = False
      realtime = False
      sys = <module 'sys' (built-in)>
      _raise_exception = <function msgprint.<locals>._raise_exception at 0x7f3effd00c10>
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = "Error Log tflpeqcsfo: 'Title' (Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz) will get truncated, as max characters allowed is 140"
      out = {'message': "Error Log tflpeqcsfo: 'Title' (Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz) will get truncated, as max characters allowed is 140", 'title': 'Value too big', 'indicator': 'red', 'raise_exception': 1, '__frappe_exc_id': 'aa0a24bf1cd0e9a3802e79441cc52b689b0bbfa85cb21b664c4329a4'}
      raise_exception = <class 'frappe.exceptions.CharacterLengthExceededError'>
  File "apps/frappe/frappe/__init__.py", line 561, in _raise_exception
    raise exc
      exc = CharacterLengthExceededError("Error Log tflpeqcsfo: 'Title' (Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz) will get truncated, as max characters allowed is 140")
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = "Error Log tflpeqcsfo: 'Title' (Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz) will get truncated, as max characters allowed is 140"
      out = {'message': "Error Log tflpeqcsfo: 'Title' (Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz) will get truncated, as max characters allowed is 140", 'title': 'Value too big', 'indicator': 'red', 'raise_exception': 1, '__frappe_exc_id': 'aa0a24bf1cd0e9a3802e79441cc52b689b0bbfa85cb21b664c4329a4'}
      raise_exception = <class 'frappe.exceptions.CharacterLengthExceededError'>
frappe.exceptions.CharacterLengthExceededError: Error Log tflpeqcsfo: 'Title' (Error saving file in remote folder: 'NoneType' object has no attribute 'put_object' File saved in local filesystem.: stock_balance_2024-8-20-12-5.json.gz) will get truncated, as max characters allowed is 140

DRF Error Log

Title

Error saving file in remote folder: 'NoneType' object has no attribute 'put_object': stock_balance_2024-16-20-12-5.json.gz

Error

'NoneType' object has no attribute 'put_object'

MrJico avatar May 20 '24 09:05 MrJico