zerodha / frappe-attachments-s3

A frappe app to upload file attachments in doctypes to s3.
Other
122 stars 143 forks source link

prepared report fails #66

Open ashish-greycube opened 8 months ago

ashish-greycube commented 8 months ago

Expected behaviour

Prepared reports should work

Actual behaviour

raceback with variables (most recent call last):
  File "apps/frappe/frappe/desk/query_report.py", line 293, in get_prepared_report_result
    if data := json.loads(doc.get_prepared_data().decode("utf-8")):
      report = <Report: General Ledger>
      filters = {'company': 'Tech India Engineers Pvt. Limited', 'from_date': '2023-04-01', 'to_date': '2024-03-20', 'account': [], 'party': [], 'group_by': 'Group by Voucher (Consolidated)', 'cost_center': [], 'project': [], 'include_dimensions': 1, 'include_default_book_entries': 1}
      dn = '70e883c13d'
      user = 'panubahire25@gmail.com'
      get_completed_prepared_report = <function get_completed_prepared_report at 0x7f09f4021630>
      get_report_data = <function get_prepared_report_result.<locals>.get_report_data at 0x7f09f2bb40d0>
      report_data = {}
      doc = <PreparedReport: 70e883c13d>
  File "apps/frappe/frappe/core/doctype/prepared_report/prepared_report.py", line 56, in get_prepared_data
    return gzip_decompress(attached_file.get_content())
      self = <PreparedReport: 70e883c13d>
      with_file_name = False
      attachments = [{'name': 'fa79dbf06d', 'file_name': '2024-59-20-9:3.json.gz', 'file_url': '/api/method/frappe_s3_attachment.controller.generate_file?key=erpnext/2024/03/20/Prepared Report/M2ZMY0IU_2024-59-20-93.json.gz&file_name=2024-59-20-9:3.json.gz', 'is_private': 1}]
      attachment = {'name': 'fa79dbf06d', 'file_name': '2024-59-20-9:3.json.gz', 'file_url': '/api/method/frappe_s3_attachment.controller.generate_file?key=erpnext/2024/03/20/Prepared Report/M2ZMY0IU_2024-59-20-93.json.gz&file_name=2024-59-20-9:3.json.gz', 'is_private': 1}
      attached_file = <File: fa79dbf06d>
  File "apps/frappe/frappe/core/doctype/file/file.py", line 472, in get_content
    self.validate_file_url()
      self = <File: fa79dbf06d>
  File "apps/frappe/frappe/core/doctype/file/file.py", line 177, in validate_file_url
    frappe.throw(
      self = <File: fa79dbf06d>
  File "apps/frappe/frappe/__init__.py", line 534, in throw
    msgprint(
      msg = 'URL must start with http:// or https://'
      exc = <class 'frappe.exceptions.ValidationError'>
      title = 'Invalid URL'
      is_minimizable = False
      wide = False
      as_list = False
  File "apps/frappe/frappe/__init__.py", line 502, in msgprint
    _raise_exception()
      title = 'Invalid URL'
      as_table = False
      as_list = False
      indicator = 'red'
      alert = False
      primary_action = None
      is_minimizable = False
      wide = False
      sys = <module 'sys' (built-in)>
      out = {'message': 'URL must start with http:// or https://', 'title': 'Invalid URL', 'indicator': 'red', 'raise_exception': 1}
      _raise_exception = <function msgprint.<locals>._raise_exception at 0x7f09f2bb5fc0>
      _strip_html_tags = <functools._lru_cache_wrapper object at 0x7f09f20decf0>
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = 'URL must start with http:// or https://'
      raise_exception = <class 'frappe.exceptions.ValidationError'>
      strip_html_tags = <function strip_html_tags at 0x7f09f70945e0>
  File "apps/frappe/frappe/__init__.py", line 451, in _raise_exception
    raise raise_exception(msg)
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = 'URL must start with http:// or https://'
      raise_exception = <class 'frappe.exceptions.ValidationError'>
frappe.exceptions.ValidationError: URL must start with http:// or https://

Step to reproduce

Go to general ledger report in v14 . it is a prepared report and it fails

Version

v14

ashish-greycube commented 8 months ago

@shridarpatil , this is bit urgent. Note we have purchased support for the app. But not sure where to raise or submit support ticket for above issue. Thanks

ashish-greycube commented 8 months ago

mostly fix should be at https://github.com/zerodha/frappe-attachments-s3/blob/master/frappe_s3_attachment/controller.py#L224

shridarpatil commented 8 months ago

This error is on which action can you give some more details?

ashish-greycube commented 8 months ago

open any prepared report image Peek 2024-03-20 11-36

ashish-greycube commented 8 months ago

@shridarpatil , let me know if any other info is required. thanks

shridarpatil commented 8 months ago

if it's urgent you can add "ignore_s3_upload_for_doctype": ["Prepared Report"] for now so that it will ignore s3 upload

anushreelimaaye commented 2 weeks ago

Not able to generate Stock Balance report. Any solution for this?