Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFTP Rename returning 404 on success (occasionally) #1298

Open
tjohnson1010 opened this issue Feb 14, 2025 · 0 comments
Open

SFTP Rename returning 404 on success (occasionally) #1298

tjohnson1010 opened this issue Feb 14, 2025 · 0 comments

Comments

@tjohnson1010
Copy link

tjohnson1010 commented Feb 14, 2025

Describe the Bug with repro steps

I have a few Logic Apps that has an action that creates a file in SFTP with a filename of tmp.{final_name} and then renames it's in another action to just {final_name}. Once in a while, the rename returns 404 even though it did rename it. The consuming party may have be picking it up right at the time it completes renaming the file. I have "Get All File Metadata" setting set to No, but I think it may still be trying to get it after renaming and the file is no longer there. Per the consuming party, the file was successfully picked up the final filename, so we know it did get renamed and the alert is false.

Full Error returned in Rename action: ("tmp.Shipping-2025-02-14@16-05-13.SME.SHUXML6c354dec-9e6d-440d-8adf-75538b31b9c5.SME.SHUXML" is the file being renamed)

{
  "status": 404,
  "message": "The provided path '/outbound/tmp.Shipping-2025-02-14@16-05-13.SME.SHUXML6c354dec-9e6d-440d-8adf-75538b31b9c5.SME.SHUXML' does not exist.\r\nclientRequestId: 2315ff9c-cc0b-4f8b-90a3-f690709e2875",
  "error": {
    "message": "The provided path '/outbound/tmp.Shipping-2025-02-14@16-05-13.SME.SHUXML6c354dec-9e6d-440d-8adf-75538b31b9c5.SME.SHUXML' does not exist."
  },
  "source": "sftpwithssh-eus.azconn-eus-002.p.azurewebsites.net"
}

What type of Logic App Is this happening in?

Consumption (Portal)

Which operating system are you using?

Windows

Did you refer to the TSG before filing this issue? https://aka.ms/lauxtsg

Yes

Workflow JSON

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "triggers": {
            "manual": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                    "schema": {
                        "properties": {
                            "Customer": {
                                "type": "string"
                            },
                            "Data": {
                                "type": "string"
                            },
                            "Filename": {
                                "type": "string"
                            },
                            "FilenameOut": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                }
            }
        },
        "actions": {
            "Exception": {
                "runAfter": {
                    "Filter_Error_Messages": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection",
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['office365']['connectionId']"
                        }
                    },
                    "method": "post",
                    "body": {
                        "To": "@parameters('emailTo')",
                        "Subject": "Exception occurred in Franklin Outbound Transfer for file : @{triggerBody()?['Filename']}",
                        "Body": "<p>Error At : @{last(body('Filter_Error_Messages'))?['name']}\n\nRun : @{workflow().run.name}\n\n@{if(equals(first(string(coalesce(last(body('Filter_Error_Messages'))?['outputs']?['body'],'{}'))),'{'),coalesce(last(body('Filter_Error_Messages'))?['outputs']?['body']?['error']?['message'],last(body('Filter_Error_Messages'))?['outputs']?['body']?['errorMessage'],last(body('Filter_Error_Messages'))?['error']?['message'],last(body('Filter_Error_Messages'))?['outputs']?['body'],last(body('Filter_Error_Messages'))?['error']),last(body('Filter_Error_Messages'))?['outputs']?['body'])}</p>",
                        "Importance": "High"
                    },
                    "path": "/v2/Mail"
                }
            },
            "Filter_Error_Messages": {
                "runAfter": {
                    "Scope": [
                        "Failed"
                    ]
                },
                "type": "Query",
                "inputs": {
                    "from": "@result('Scope')",
                    "where": "@equals(item()['status'], 'Failed')"
                }
            },
            "Scope": {
                "actions": {
                    "Create_SPO": {
                        "runAfter": {
                            "Send_To": [
                                "Succeeded"
                            ]
                        },
                        "type": "ApiConnection",
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['sharepointonline']['connectionId']"
                                }
                            },
                            "method": "post",
                            "body": "@triggerBody()?['Data']",
                            "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://XXXXX.sharepoint.com/sites/XXX'))}/files",
                            "queries": {
                                "folderPath": "/Shared Documents/@{if(equals(triggerBody()?['Customer'],'EEE'),'FFF',triggerBody()?['Customer'])}/Sent",
                                "name": "@{triggerBody()?['FilenameOut']}@{if(endsWith(triggerBody()?['FilenameOut'],'XML'),'.xml',if(equals(lastIndexOf(triggerBody()?['FilenameOut'],'.'),-1),'.txt',''))}",
                                "queryParametersSingleEncoded": true
                            }
                        }
                    },
                    "Response": {
                        "runAfter": {
                            "Create_SPO": [
                                "Succeeded"
                            ]
                        },
                        "type": "Response",
                        "kind": "Http",
                        "inputs": {
                            "statusCode": 200
                        }
                    },
                    "Response_Error": {
                        "runAfter": {
                            "Send_To": [
                                "Failed"
                            ]
                        },
                        "type": "Response",
                        "kind": "Http",
                        "inputs": {
                            "statusCode": 200
                        }
                    },
                    "Send_To": {
                        "cases": {
                            "FFF": {
                                "case": "FFF",
                                "actions": {
                                    "Create_FFF_File": {
                                        "type": "ApiConnection",
                                        "inputs": {
                                            "host": {
                                                "connection": {
                                                    "name": "@parameters('$connections')['sftpwithssh']['connectionId']"
                                                }
                                            },
                                            "method": "post",
                                            "body": "@triggerBody()?['Data']",
                                            "headers": {
                                                "ReadFileMetadataFromServer": false
                                            },
                                            "path": "/datasets/default/files",
                                            "queries": {
                                                "folderPath": "/outbound",
                                                "name": "tmp.@{triggerBody()?['Filename']}",
                                                "queryParametersSingleEncoded": true
                                            },
                                            "retryPolicy": {
                                                "type": "fixed",
                                                "count": 10,
                                                "interval": "PT10S"
                                            }
                                        },
                                        "runtimeConfiguration": {
                                            "contentTransfer": {
                                                "transferMode": "Chunked"
                                            }
                                        }
                                    },
                                    "Rename_File": {
                                        "runAfter": {
                                            "Create_FFF_File": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "ApiConnection",
                                        "inputs": {
                                            "host": {
                                                "connection": {
                                                    "name": "@parameters('$connections')['sftpwithssh-1']['connectionId']"
                                                }
                                            },
                                            "method": "post",
                                            "headers": {
                                                "ReadFileMetadataFromServer": false
                                            },
                                            "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(body('Create_FFF_File')?['Path']))}/rename",
                                            "queries": {
                                                "newName": "@triggerBody()?['Filename']"
                                            }
                                        }
                                    }
                                }
                            },
                            "EEE": {
                                "case": "EEE",
                                "actions": {
                                    "Create_EEE_File": {
                                        "type": "ApiConnection",
                                        "inputs": {
                                            "host": {
                                                "connection": {
                                                    "name": "@parameters('$connections')['sftpwithssh_1']['connectionId']"
                                                }
                                            },
                                            "method": "post",
                                            "body": "@triggerBody()?['Data']",
                                            "headers": {
                                                "ReadFileMetadataFromServer": false
                                            },
                                            "path": "/datasets/default/files",
                                            "queries": {
                                                "folderPath": "/outbound",
                                                "name": "@triggerBody()?['FilenameOut']",
                                                "queryParametersSingleEncoded": true
                                            },
                                            "retryPolicy": {
                                                "type": "fixed",
                                                "count": 10,
                                                "interval": "PT10S"
                                            }
                                        },
                                        "runtimeConfiguration": {
                                            "contentTransfer": {
                                                "transferMode": "Chunked"
                                            }
                                        }
                                    }
                                }
                            },
                            "EEE_via_xSIP": {
                                "case": "XEEE",
                                "actions": {
                                    "Create_EEE_File_in_xSIP_": {
                                        "type": "ApiConnection",
                                        "inputs": {
                                            "host": {
                                                "connection": {
                                                    "name": "@parameters('$connections')['sftpwithssh_2']['connectionId']"
                                                }
                                            },
                                            "method": "post",
                                            "body": "@triggerBody()?['Data']",
                                            "headers": {
                                                "ReadFileMetadataFromServer": false
                                            },
                                            "path": "/datasets/default/files",
                                            "queries": {
                                                "folderPath": "/outbound/www",
                                                "name": "@{triggerBody()?['FilenameOut']}.partial",
                                                "queryParametersSingleEncoded": true
                                            },
                                            "retryPolicy": {
                                                "type": "fixed",
                                                "count": 10,
                                                "interval": "PT10S"
                                            }
                                        },
                                        "runtimeConfiguration": {
                                            "contentTransfer": {
                                                "transferMode": "Chunked"
                                            }
                                        }
                                    },
                                    "Rename_EEE_File_in_xSIP": {
                                        "runAfter": {
                                            "Create_EEE_File_in_xSIP_": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "ApiConnection",
                                        "inputs": {
                                            "host": {
                                                "connection": {
                                                    "name": "@parameters('$connections')['sftpwithssh_3']['connectionId']"
                                                }
                                            },
                                            "method": "post",
                                            "headers": {
                                                "ReadFileMetadataFromServer": false
                                            },
                                            "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(body('Create_EEE_File_in_xSIP_')?['Path']))}/rename",
                                            "queries": {
                                                "newName": "@triggerBody()?['FilenameOut']"
                                            },
                                            "retryPolicy": {
                                                "type": "fixed",
                                                "count": 10,
                                                "interval": "PT10S"
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "default": {
                            "actions": {
                                "Send_an_Unknown_Customer_Alert": {
                                    "type": "ApiConnection",
                                    "inputs": {
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['office365']['connectionId']"
                                            }
                                        },
                                        "method": "post",
                                        "body": {
                                            "To": "@parameters('emailTo')",
                                            "Subject": "Exception in Franklin Outbound Transfer : Unknown Customer ",
                                            "Body": "<p>Filename : @{triggerBody()?['Filename']}\n\nCustomer : @{triggerBody()?['Customer']}\n\nRun : @{workflow().run.name}</p>",
                                            "Importance": "High"
                                        },
                                        "path": "/v2/Mail"
                                    }
                                },
                                "Terminate": {
                                    "runAfter": {
                                        "Send_an_Unknown_Customer_Alert": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "Terminate",
                                    "inputs": {
                                        "runStatus": "Failed",
                                        "runError": {
                                            "code": "409",
                                            "message": "Unknown Customer"
                                        }
                                    }
                                }
                            }
                        },
                        "expression": "@triggerBody()?['Customer']",
                        "type": "Switch"
                    }
                },
                "runAfter": {},
                "type": "Scope"
            }
        },
        "outputs": {},
        "parameters": {
            "emailTo": {
                "defaultValue": "email@domain.com",
                "type": "String"
            },
            "$connections": {
                "type": "Object",
                "defaultValue": {}
            }
        }
    },
    "parameters": {
        "$connections": {
            "type": "Object",
            "value": {
                "office365": {
                    "id": "/subscriptions/XXXXX/providers/Microsoft.Web/locations/eastus/managedApis/office365",
                    "connectionId": "/subscriptions/XXXXX/resourceGroups/Franklin/providers/Microsoft.Web/connections/office365",
                    "connectionName": "office365"
                },
                "sharepointonline": {
                    "id": "/subscriptions/XXXXX/providers/Microsoft.Web/locations/eastus/managedApis/sharepointonline",
                    "connectionId": "/subscriptions/XXXXX/resourceGroups/Franklin/providers/Microsoft.Web/connections/sharepointonline",
                    "connectionName": "sharepointonline"
                },
                "sftpwithssh": {
                    "id": "/subscriptions/XXXXX/providers/Microsoft.Web/locations/eastus/managedApis/sftpwithssh",
                    "connectionId": "/subscriptions/XXXXX/resourceGroups/Franklin/providers/Microsoft.Web/connections/sftpwithssh-8",
                    "connectionName": "sftpwithssh-8"
                },
                "sftpwithssh-1": {
                    "id": "/subscriptions/XXXXX/providers/Microsoft.Web/locations/eastus/managedApis/sftpwithssh",
                    "connectionId": "/subscriptions/XXXXX/resourceGroups/Franklin/providers/Microsoft.Web/connections/sftpwithssh-10",
                    "connectionName": "sftpwithssh-10"
                },
                "sftpwithssh_1": {
                    "id": "/subscriptions/XXXXX/providers/Microsoft.Web/locations/eastus/managedApis/sftpwithssh",
                    "connectionId": "/subscriptions/XXXXX/resourceGroups/Franklin/providers/Microsoft.Web/connections/sftpwithssh-1",
                    "connectionName": "sftpwithssh-1"
                },
                "sftpwithssh_2": {
                    "id": "/subscriptions/XXXXX/providers/Microsoft.Web/locations/eastus/managedApis/sftpwithssh",
                    "connectionId": "/subscriptions/XXXXX/resourceGroups/Franklin/providers/Microsoft.Web/connections/sftpwithssh-2",
                    "connectionName": "sftpwithssh-2"
                },
                "sftpwithssh_3": {
                    "id": "/subscriptions/XXXXX/providers/Microsoft.Web/locations/eastus/managedApis/sftpwithssh",
                    "connectionId": "/subscriptions/XXXXX/resourceGroups/Franklin/providers/Microsoft.Web/connections/sftpwithssh-11",
                    "connectionName": "sftpwithssh-11"
                }
            }
        }
    }
}

Screenshots or Videos

No response

Browser

Microsoft Edge for Business

Version 133.0.3065.59 (Official build) (64-bit)

Additional context

No response

@hartra344 hartra344 transferred this issue from Azure/LogicAppsUX Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant