Skip to content
TheChatArchiveThe Chat Archive
o1-mini-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

frappe-ui.js?v=1dbcb8cc:13155 Traceback (most recent call last): File…

  1. User

    frappe-ui.js?v=1dbcb8cc:13155 Traceback (most recent call last): File "apps/frappe/frappe/app.py", line 114, in application response = frappe.api.handle(request) File "apps/frappe/frappe/api/init.py", line 49, in handle data = endpoint(**arguments) File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call return frappe.handler.handle() File "apps/frappe/frappe/handler.py", line 49, in handle data = execute_cmd(cmd) File "apps/frappe/frappe/handler.py", line 85, in execute_cmd return frappe.call(method, **frappe.form_dict) File "apps/frappe/frappe/init.py", line 1768, in call return fn(*args, **newargs) File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper return func(*args, **kwargs) File "apps/frappe/frappe/client.py", line 188, in set_value doc.save() File "apps/frappe/frappe/model/document.py", line 337, in save return self._save(*args, **kwargs) File "apps/frappe/frappe/model/document.py", line 389, in _save self.update_children() File "apps/frappe/frappe/model/document.py", line 421, in update_children self.update_child_table(df.fieldname, df) File "apps/frappe/frappe/model/document.py", line 453, in update_child_table d.db_update() File "apps/frappe/frappe/model/base_document.py", line 615, in db_update frappe.db.sql( File "apps/frappe/frappe/database/database.py", line 234, in sql self._cursor.execute(query, values) File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 151, in execute query = self.mogrify(query, args) File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 129, in mogrify query = query % self._escape_args(args, conn) File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 102, in _escape_args return tuple(conn.literal(arg) for arg in args) File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 102, in return tuple(conn.literal(arg) for arg in args) File "env/lib/python3.10/site-packages/pymysql/connections.py", line 530, in literal return self.escape(obj, self.encoders) File "env/lib/python3.10/site-packages/pymysql/connections.py", line 523, in escape return converters.escape_item(obj, self.charset, mapping=mapping) File "env/lib/python3.10/site-packages/pymysql/converters.py", line 23, in escape_item val = encoder(val, charset, mapping) File "env/lib/python3.10/site-packages/pymysql/converters.py", line 30, in escape_dict raise TypeError("dict can not be used as parameter") TypeError: dict can not be used as parameter

    verificationRequest.ts:217 Error updating document fields: SyntaxError: "undefined" is not valid JSON at JSON.parse () at revertRowInListResource (frappe-ui.js?v=1dbcb8cc:12798:38) at onError (frappe-ui.js?v=1dbcb8cc:12852:7) at handleError (frappe-ui.js?v=1dbcb8cc:12429:13) at Proxy.fetch2 (frappe-ui.js?v=1dbcb8cc:12393:7) at async Proxy.updateDocumentFields (verificationRequest.ts:214:9) at async Proxy.saveStep3 (verificationRequest.ts:535:9) at async Proxy.saveEmployment (step3.vue:575:5) updateDocumentFields @ verificationRequest.ts:217 await in updateDocumentFields wrappedAction @ pinia.js?v=1dbcb8cc:1228 store. @ pinia.js?v=1dbcb8cc:920 saveStep3 @ verificationRequest.ts:535 wrappedAction @ pinia.js?v=1dbcb8cc:1228 store. @ pinia.js?v=1dbcb8cc:920 saveEmployment @ step3.vue:575 onClicked @ step3.vue:366 callWithErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2152 callWithAsyncErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2159 emit @ chunk-4G2AIOYC.js?v=1dbcb8cc:7234 (anonymous) @ chunk-4G2AIOYC.js?v=1dbcb8cc:8577 emit @ button.vue:41 callWithErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2152 callWithAsyncErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2159 invoker @ chunk-4G2AIOYC.js?v=1dbcb8cc:9561 Show 11 more frames Show less verificationRequest.ts:538 حدث خطأ أثناء حفظ بيانات التوظيف: Error: Error updating document fields at Proxy.updateDocumentFields (verificationRequest.ts:219:15) at async Proxy.saveStep3 (verificationRequest.ts:535:9) at async Proxy.saveEmployment (step3.vue:575:5) saveStep3 @ verificationRequest.ts:538 await in saveStep3 wrappedAction @ pinia.js?v=1dbcb8cc:1228 store. @ pinia.js?v=1dbcb8cc:920 saveEmployment @ step3.vue:575 onClicked @ step3.vue:366 callWithErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2152 callWithAsyncErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2159 emit @ chunk-4G2AIOYC.js?v=1dbcb8cc:7234 (anonymous) @ chunk-4G2AIOYC.js?v=1dbcb8cc:8577 emit @ button.vue:41 callWithErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2152 callWithAsyncErrorHandling @ chunk-4G2AIOYC.js?v=1dbcb8cc:2159 invoker @ chunk-4G2AIOYC.js?v=1dbcb8cc:9561 Show 9 more frames Show less step3.vue:578 Failed to save employment 1: Error: Error updating document fields at Proxy.updateDocumentFields (verificationRequest.ts:219:15) at async Proxy.saveStep3 (verificationRequest.ts:535:9) at async Proxy.saveEmployment (step3.vue:575:5)

  2. Assistant

    The error logs you've provided indicate that there's an issue occurring both on the server side (Frappe framework) and the client side (likely a frontend application using Vue.js with Frappe's UI components). Let's break down the problem and provide steps to diagnose and resolve it.

    Understanding the Error

    1. Server-Side Error (TypeError: dict can not be used as parameter):

      • Source: The error originates from the pymysql library while attempting to execute an SQL query.
      • Cause: A dictionary (dict) is being passed as a parameter to an SQL query where a scalar value or a tuple is expected. SQL parameters should generally be strings, numbers, or other primitive types, not dictionaries.
    2. Client-Side Error (SyntaxError: "undefined" is not valid JSON):

      • Source: The frontend application is attempting to parse a response from the server.
      • Cause: Since the server encountered an error before sending a valid JSON response, the frontend receives an unexpected undefined value, leading to a JSON parsing error.

    Potential Causes

    1. Incorrect Data Assignment:

      • A field in your Frappe document might be incorrectly assigned a dictionary instead of a scalar value. For instance, setting a field that expects a string or number to a dictionary object.
    2. Custom Scripts or Overrides:

      • Custom scripts (client-side or server-side) might be modifying the document in a way that introduces a dictionary where it's not expected.
    3. Database Schema Issues:

      • The database schema might have discrepancies, especially if custom fields have been added or modified improperly.

    Steps to Diagnose and Resolve

    1. Identify the Faulty Field:

      • Review Recent Changes: Think about any recent changes you've made to the form or the backend code that might affect the document being saved.
      • Check Custom Fields: Ensure that any custom fields added to the document are of the correct data type and are being populated with appropriate values.
    2. Inspect Server-Side Code:

      • Trace the Error Stack:
        • The error occurs in frappe/client.py at line 188 during the set_value method, which eventually calls doc.save().
        • The issue arises when db_update is called, indicating that the document's data being prepared for saving contains an unexpected dictionary.
      • Add Logging:
        • Temporarily add logging statements before the doc.save() call to print out the document's data. This can help identify which field contains the dictionary.
        import frappe
        
        @frappe.whitelist()
        def set_value(...):
            # Existing code
            frappe.logger().debug(f"Document before save: {doc.as_dict()}")
            doc.save()
        
      • Check for Nested Dictionaries:
        • Ensure that no fields are unintentionally set to nested dictionaries unless they are of type JSON or similar that can handle such data.
    3. Validate Client-Side Data:

      • Check Data Binding:
        • On the client side (e.g., in your Vue components), ensure that the data being sent to the server is correctly structured. Avoid assigning objects to fields that expect primitive values.
      • Use Developer Tools:
        • Utilize browser developer tools to inspect the network requests. Verify the payload being sent when attempting to save the document. Ensure that all fields have valid JSON-serializable values.
    4. Test with Minimal Data:

      • Isolate the Issue:
        • Try saving the document with minimal data to see if the error persists. Gradually add fields back to identify which one causes the issue.
      • Example:
        • Start by saving only essential fields.
        • If successful, add additional fields one by one until the error reappears.
    5. Review Field Definitions:

      • Frappe Doctype Definitions:
        • Go to the Frappe desk, navigate to the relevant Doctype, and verify that all fields are defined with the correct types.
      • Example:
        • If a field is meant to store JSON data, ensure its type is set to JSON or Code.
    6. Update Dependencies:

      • Pymysql Version:
        • Ensure that the pymysql library is up-to-date and compatible with your Frappe version.
        • You can update it using:
          pip install --upgrade pymysql
          
      • Frappe and ERPNext Versions:
        • Ensure that your Frappe and ERPNext installations are up-to-date with the latest patches that might address known issues.
    7. Handle Exceptions Gracefully:

      • Custom Error Handling:
        • Implement try-except blocks around critical sections to handle unexpected data types and provide more informative error messages.
      • Example:
        try:
            doc.save()
        except TypeError as e:
            frappe.log_error(message=str(e), title="Error Saving Document")
            frappe.throw(_("An error occurred while saving the document. Please contact support."))
        
    8. Consult Frappe Documentation and Community:

      • Documentation:
      • Community Support:
        • Engage with the Frappe community forums or relevant support channels. Provide them with the error logs and steps you've taken for more targeted assistance.

    Summary

    The core issue lies in passing a dictionary where a scalar value is expected in an SQL operation within Frappe. By systematically inspecting both your server-side and client-side code, verifying field definitions, and ensuring that data being saved adheres to expected types, you can identify and resolve the root cause of the error.

    If after following these steps the issue persists, please provide more context or specific code snippets related to the document fields you're trying to update. This additional information can help in offering more precise guidance.