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

Conversation created partially on api failure of create conversation #3871

Closed
anjan-rpf opened this issue Mar 13, 2024 · 11 comments
Closed

Conversation created partially on api failure of create conversation #3871

anjan-rpf opened this issue Mar 13, 2024 · 11 comments

Comments

@anjan-rpf
Copy link

Issue: Create Conversation api is creating a convo partially on API failure

Steps to reproduce:

  1. I encountered this issue when threads have an attachment that doesn't have the required permission.
  2. When a conversation is created due to permission issue in the attachment url the API fails ( which is expected )
  3. But the conversation is still created

Expected:
On Create Conversation API failure conversation shouldn't be created in the mailbox

@freescout-helpdesk
Copy link
Contributor

I encountered this issue when threads have an attachment that doesn't have the required permission.

What does it mean?

@anjan-rpf
Copy link
Author

anjan-rpf commented Mar 13, 2024

PFA threads part of the request for create conversation.

Here when the API is called freescout tries to access the fileName from s3. due to lack of permission from s3 api fails ( which is expected ) but the conversation is created partially.

LMK if more info is needed

{
// other fields
    "threads": [
      
        {
            "text": "Added attachments",
            "type": "note",
            "user": 1,
            "attachments": [
                {
                    "fileName": "file_name",
                    "fileUrl": "file_url",
                    "mimeType": "image/jpeg"
                }
            ]
        }
     // other threads
    ],

// other fields
}

@freescout-helpdesk
Copy link
Contributor

freescout-helpdesk commented Mar 13, 2024

This is how it works. It's your duty to make sure that attachment URL is available.

@anjan-rpf
Copy link
Author

yes agree,

but when attachement URL is not available the create convo API throws an error, in this case can we not create a conversation partially?

@freescout-helpdesk
Copy link
Contributor

API throws an error

Can you post it here?

@anjan-rpf
Copy link
Author

response:
500 internal server error

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Error</title>

        <!-- Fonts -->
        <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

        <!-- Styles -->
        <style>
            html, body {
                background-color: #fff;
                color: #636b6f;
                font-family: 'Raleway', sans-serif;
                font-weight: 100;
                height: 100vh;
                margin: 0;
            }

            .full-height {
                height: 100vh;
            }

            .flex-center {
                align-items: center;
                display: flex;
                justify-content: center;
            }

            .position-ref {
                position: relative;
            }

            .content {
                text-align: center;
            }

            .title {
                font-size: 36px;
                padding: 20px;
            }
        </style>
    </head>
    <body>
        <div class="flex-center position-ref full-height">
            <div class="content">
                <div class="title">
                    Whoops, looks like something went wrong — check logs in /storage/logs                </div>
            </div>
        </div>
    </body>
</html>

@sarsony1
Copy link

sarsony1 commented Mar 13, 2024

@freescout-helpdesk I think there is small confusion here. To make things clear,
The attachment URL in the CreateConversation API call is available and freescout is able to download it. We did make a change to use s3 as backend instead of local file system. Due to some permission issue with upload, the create convo failed. We were able to identify the issue, and now everything is fine.

What I think is an issue though is when the CreateConversation API returned an error why is the conversation still created. Its a single create call with threads embedded in the request

@sarsony1
Copy link

I get that Create Conversation failed because some of the threads were not created due to some error. But it being a single request, shouldn't the entire thing be atomic.

@freescout-helpdesk
Copy link
Contributor

500 internal server error

Can you send the actual full error message from Manage > Logs > App Logs.

@anjan-rpf
Copy link
Author

Error executing "PutObject" on "https://url-to-s3-bucket"; AWS HTTP error: Client error: PUT https://url-to-s3-bucket resulted in a 403 Forbidden response:

full error AccessDeniedAccess Denied1P4QSC (truncated...) AccessDenied (client): Access Denied - AccessDeniedAccess Denied1P4QSCXFA8T71CFHWSL0D4TXs6LA5HXdAA7TLLZt8vRsax98iTRVe6PSvCVRWX+c8V2UEyR/mVIzUB5KMoAb8NGsfok= {"exception":"[object] (Aws\\S3\\Exception\\S3Exception(code: 0): Error executing \"PutObject\" on \"https://url-to-s3-bucket\"; AWS HTTP error: Client error: `PUT https://url-to-s3-bucket` resulted in a `403 Forbidden` response: AccessDeniedAccess Denied1P4QSC (truncated...) AccessDenied (client): Access Denied - AccessDeniedAccess Denied1P4QSCXFA8T71CFHWSL0D4TXs6LA5HXdAA7TLLZt8vRsax98iTRVe6PSvCVRWX+c8V2UEyR/mVIzUB5KMoAb8NGsfok= at /var/www/vhosts/current/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:196, GuzzleHttp\\Exception\\ClientException(code: 403): Client error: `PUT https://url-to-s3-bucket` resulted in a `403 Forbidden` response: AccessDeniedAccess Denied1P4QSC (truncated...) at /var/www/vhosts/current/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113) [stacktrace] #0 /var/www/vhosts/current/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(98): Aws\\WrappedHttpHandler->parseError() #1 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(204): Aws\\WrappedHttpHandler->Aws\\{closure}() #2 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(169): GuzzleHttp\\Promise\\Promise::callHandler() #3 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/RejectedPromise.php(42): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}() #4 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\\Promise\\RejectedPromise::GuzzleHttp\\Promise\\{closure}() #5 /var/www/vhosts/current/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(118): GuzzleHttp\\Promise\\TaskQueue->run() #6 /var/www/vhosts/current/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(145): GuzzleHttp\\Handler\\CurlMultiHandler->tick() #7 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\\Handler\\CurlMultiHandler->execute() #8 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\\Promise\\Promise->invokeWaitFn() #9 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\\Promise\\Promise->waitIfPending() #10 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\\Promise\\Promise->invokeWaitList() #11 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\\Promise\\Promise->waitIfPending() #12 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\\Promise\\Promise->invokeWaitList() #13 /var/www/vhosts/current/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending() #14 /var/www/vhosts/current/vendor/aws/aws-sdk-php/src/S3/S3ClientTrait.php(35): GuzzleHttp\\Promise\\Promise->wait() #15 /var/www/vhosts/current/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php(607): Aws\\S3\\S3Client->upload() #16 /var/www/vhosts/current/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php(392): League\\Flysystem\\AwsS3v3\\AwsS3Adapter->upload() #17 /var/www/vhosts/current/vendor/league/flysystem/src/Filesystem.php(123): League\\Flysystem\\AwsS3v3\\AwsS3Adapter->writeStream() #18 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(179): League\\Flysystem\\Filesystem->putStream() #19 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(213): Illuminate\\Filesystem\\FilesystemAdapter->put() #20 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php(85): Illuminate\\Filesystem\\FilesystemAdapter->putFileAs() #21 /var/www/vhosts/current/app/Attachment.php(154): Illuminate\\Http\\UploadedFile->storeAs() #22 /var/www/vhosts/current/app/Attachment.php(126): App\\Attachment::saveFileToDisk() #23 /var/www/vhosts/current/Modules/ApiWebhooks/Http/Controllers/ApiController.php(997): App\\Attachment::create() #24 /var/www/vhosts/current/Modules/ApiWebhooks/Http/Controllers/ApiController.php(758): Modules\\ApiWebhooks\\Http\\Controllers\\ApiController->createThread() #25 [internal function]: Modules\\ApiWebhooks\\Http\\Controllers\\ApiController->createConversation() #26 /var/www/vhosts/current/overrides/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array() #27 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction() #28 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch() #29 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\\Routing\\Route->runController() #30 /var/www/vhosts/current/overrides/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Route->run() #31 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}() #32 /var/www/vhosts/current/Modules/ApiWebhooks/Http/Middleware/ApiAuth.php(32): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #33 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Modules\\ApiWebhooks\\Http\\Middleware\\ApiAuth->handle() #34 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #35 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #36 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle() #37 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #38 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #39 /var/www/vhosts/current/overrides/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then() #40 /var/www/vhosts/current/overrides/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack() #41 /var/www/vhosts/current/overrides/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute() #42 /var/www/vhosts/current/overrides/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute() #43 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch() #44 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}() #45 /var/www/vhosts/current/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(58): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #46 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle() #47 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #48 /var/www/vhosts/current/app/Http/Middleware/TerminateHandler.php(12): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #49 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\\Http\\Middleware\\TerminateHandler->handle() #50 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #51 /var/www/vhosts/current/app/Http/Middleware/ResponseHeaders.php(11): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #52 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\\Http\\Middleware\\ResponseHeaders->handle() #53 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #54 /var/www/vhosts/current/vendor/fideloper/proxy/src/TrustProxies.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #55 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Fideloper\\Proxy\\TrustProxies->handle() #56 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #57 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #58 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle() #59 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #60 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #61 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle() #62 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #63 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #64 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle() #65 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #66 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #67 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle() #68 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #69 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() #70 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then() #71 /var/www/vhosts/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter() #72 /var/www/vhosts/current/public/index.php(83): Illuminate\\Foundation\\Http\\Kernel->handle() #73 {main} "}

@freescout-helpdesk
Copy link
Contributor

Fixed in the master branch and will be published in the next release.

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

3 participants