Why am I seeing a new Python error when copying code snippets from an active workflow?

This topic was automatically generated from Slack. You can find the original thread here.

I’m seeing a new Python error when I copied code snippets that currently work in an active workflow, the error is: Command failed: pipreqs --force INFO: Not scanning for jupyter notebooks. ERROR: Failed on file: /tmp/__pdg__/dist/code/51c1c56ee23cdd281df26351cfb5b2c769ac6cc09b2aaa06cf56f40f0cb936c6/code.py Traceback (most recent call last):

Based on the error message you’re encountering, it seems like the issue arises during the process of handling Python package requirements for your code. The pipreqs command, which attempts to generate a requirements.txt file based on imports in your Python script, is failing. This could be due to a variety of reasons, including the presence of unsupported packages, syntax errors, or environment-specific issues. Given the context, here are a few steps you can take to troubleshoot and potentially resolve the issue: 1. Review the Python Code: Ensure that the Python code you’ve copied does not contain syntax errors or references to packages that might not be supported in the Pipedream environment. Some Python packages require binaries or have dependencies that are not compatible with the Pipedream workflow environment. 2. Package Compatibility: If your workflow relies on specific Python packages, verify their compatibility with Pipedream. As mentioned in the Pipedream documentation, some packages may require binaries or are not compatible due to their dependencies. If you encounter issues with a specific package, consider reaching out on Pipedream’s GitHub issues page for further assistance. 3. Pinning Package Versions: If the issue might be related to a recent update in a Python package that your code depends on, consider pinning the package version to a previous, stable release. This can be done by specifying the package version directly in your Python code using the magic comment system for version pinning. More details on pinning package versions can be found in the Pipedream documentation on troubleshooting new package versions issues. 4. Pipedream Support: If after trying the above steps, you’re still facing issues, it might be beneficial to reach out to Pipedream’s support for more personalized assistance. You can visit Support - Pipedream for more support options. Remember, when working with external packages in Pipedream’s Python environment, it’s crucial to ensure compatibility and proper versioning to avoid runtime errors.

the error was also appearing when I wrote a new line of python code, specifically the Python String rsplit() Method. is there a Python library that needs to be included to use these standard methods?

No, you do not need to include a separate Python library to use standard methods like rsplit() in Python code on Pipedream. These methods are part of the standard Python library, which is available by default in any Python environment, including Pipedream’s Python runtime. If you’re encountering an error with the rsplit() method or any other standard Python method, the issue might be related to how the method is being used rather than the availability of the method itself. Please ensure that the syntax and usage are correct according to Python’s documentation. For example, the rsplit() method is used on strings to split the string from the right at the specified separator and returns a list of strings. Here’s a basic usage example: ```
def handler(pd: “pipedream”): # Example string text = “apple,banana,cherry” # Using rsplit() to split the string from the right at the comma separator result = text.rsplit(“,”, 1) # This will return [‘apple,banana’, ‘cherry’] print(result)

here is the code example where the rsplit() method is causing the error:

import json
def handler(pd: “pipedream”):

#Store new Tag Value found in the API Call
NewTag = pd.steps[“trigger”][“event”][“body”][“tags”][0]

#Get Customer ID from Shopify
RAWID = pd.steps[“trigger”][“event”][“body”][“customerId”]

CustID = RAWID.rsplit(“r/”, 1)

It looks like you’re encountering an issue with the rsplit() method in a Python code step within a Pipedream workflow. The rsplit() method is used to split a string from the right side based on the specified separator. In your case, it seems you’re trying to split the RAWID string to extract the Customer ID from a Shopify event. However, without the specific error message, it’s a bit challenging to pinpoint the exact issue. Common problems with rsplit() could be related to calling it on a non-string object or other syntax errors. Assuming RAWID is a string and contains the separator “r/”, your usage of rsplit() looks syntactically correct. Here’s a slightly modified version of your code with added error handling to ensure RAWID is a string and contains the separator before attempting to split it. This might help in debugging the issue: import json def handler(pd: "pipedream"): # Store new Tag Value found in the API Call NewTag = pd.steps["trigger"]["event"]["body"]["tags"][0] # Get Customer ID from Shopify RAWID = pd.steps["trigger"]["event"]["body"]["customerId"] # Ensure RAWID is a string and contains the separator if isinstance(RAWID, str) and "r/" in RAWID: CustID = RAWID.rsplit("r/", 1)[1] else: # Handle the case where RAWID is not a string or does not contain "r/" print("RAWID is not a string or does not contain the expected separator.") # Optionally, set CustID to None or a default value CustID = None # Continue with your code, using CustID This code checks if RAWID is a string and contains the “r/” separator before attempting to split it, which should help avoid errors related to the rsplit() method. If RAWID does not meet these conditions, it prints a message, and you can handle this case as needed (e.g., setting CustID to None or a default value). If you’re still encountering issues, could you please provide more details about the error message you’re seeing? This information would help in providing a more accurate solution.

It was a syntax error and using this input field to paste the error message (which was truncated ) help to narrow down the issue with extra indentions that snuck into the code

for the Update Account action (shown here: Update Account - Pipedream) how do you set a value for a custom field? the drop down for “Field Selector” doesn’t load any custom fields for the Account object, how can we update custom fields?

To update a custom field for the “Update Account” action in Salesforce using Pipedream, you can manually specify the API name of the custom field in the “Field Selector” dropdown if it doesn’t automatically load custom fields. Custom fields in Salesforce are typically denoted by an API name that ends with __c. Here’s a step-by-step guide on how you might approach this: 1. Identify the API name of the custom field you want to update. You can find this information in your Salesforce setup under Object Manager → Account → Fields & Relationships. The API name will be listed there, and for custom fields, it usually ends with __c. 2. In the Pipedream workflow editor, when configuring the “Update Account” action for Salesforce, click on the “Field Selector” dropdown. 3. If the custom field you’re looking to update does not appear in the dropdown, you can manually enter the API name of the custom field. Make sure to include the __c suffix if it’s a custom field. 4. After selecting or entering the custom field, provide the value you want to set for this field in the corresponding value input. 5. Save the action and test the workflow to ensure the custom field is updated as expected. If you encounter any issues or need further assistance, you can visit Pipedream’s support page for more help.

when I followed step 3 aboe to enter the custom field name including the __c suffix, I receive this error “Type Error
selector.reduce is not a function”

Based on the information provided, it seems like you encountered an error while following a specific step that involves entering a custom field name with a __c suffix. The error message you received, “Type Error selector.reduce is not a function,” suggests there might be an issue with how the input is being processed or a possible bug in the implementation. To better assist you, could you please provide more details about the context in which you encountered this error? Specifically, it would be helpful to know: 1. The specific step or process you were following when you encountered this error. You mentioned “step 3 above,” but I need more details about what this step involves. 2. The platform or tool where you are trying to enter the custom field name. Is this related to a specific Pipedream component or another software tool? 3. Any code snippet or configuration you can share that leads to this error. This will help in identifying the root cause of the issue. Understanding these details will enable me to provide you with more accurate guidance or a solution to resolve the error you’re experiencing.

here is a screenshot of the setup for the Salesforce Update Account Action for a custom field with the API name Tag_Summary__c

It appears there was an issue with the user’s question as it seems incomplete and does not provide a clear question or context regarding the Salesforce Update Account Action or the custom field Tag_Summary__c. Additionally, there are no attachments or screenshots provided in the text that could offer more details. Given the information provided, it’s challenging to provide a specific answer or guidance without further context. Could you please provide more details about what you’re trying to achieve with the Salesforce Update Account Action and the custom field Tag_Summary__c? Are you looking for guidance on how to set up this action in a Pipedream workflow, or are you encountering an issue that you need help with? Any additional information or clarification would be greatly appreciated to give you the most accurate and helpful response.

here is a screenshot of the setup for the Salesforce Update Account Action for a custom field with the API name Tag_Summary__c

It appears you’re encountering a TypeError: selector.reduce is not a function error while setting up the Salesforce Update Account Action, specifically when configuring a custom field with the API name Tag_Summary__c. This error typically occurs when the expected input format does not match what the function is receiving, suggesting an issue with how the Field Selector is being processed or interpreted. Without direct access to the Salesforce integration documentation or the specific implementation details of the Salesforce Update Account Action within Pipedream, I can offer some general advice on troubleshooting and resolving this issue: 1. Verify Field API Name: Ensure that Tag_Summary__c is the correct API name of the custom field in Salesforce. A mismatch in the API name could lead to unexpected errors. 2. Check Input Format: The error message suggests there might be an issue with how input is being passed to a function expecting an array or list. Review the configuration to ensure that the Field Selector is correctly formatted and matches the expected input structure. 3. Review Optional Fields: If there are any optional fields being used in the configuration, double-check their setup. An incorrectly configured optional field might lead to unexpected behavior. 4. Consult Pipedream Support: For more specific guidance and troubleshooting, consider reaching out to Pipedream’s support team. You can find additional support options at Support - Pipedream. Given the nature of the error and the information provided, these steps should help in diagnosing and potentially resolving the issue. If the problem persists, providing more details about the configuration and the steps leading up to the error could be helpful in offering more targeted advice.

using the Update Record action instead of Update Account did the trick. Therefore the update Account action for SalesForce is buggy and difficult to use for custom fields.

It seems like you’ve encountered an issue with the Salesforce “Update Account” action and found that using the “Update Record” action works better for your use case, especially when dealing with custom fields. I’m sorry for any inconvenience this may have caused. While I can’t directly fix or investigate bugs in Pipedream’s Salesforce actions, your feedback is valuable for improving the platform. For any specific issues or detailed feedback on the Salesforce integration, I recommend reaching out to the Pipedream support team. They can provide more direct assistance and escalate any bugs or feature requests to the development team. You can contact support by visiting Support - Pipedream. If you have any more questions or need further assistance with your workflows or actions in Pipedream, feel free to ask.