'Lumen unusual return value only when tried in Android (Kotlin)

I have a problem about unusual return in my lumen app version 7.

My teammate who is using kotlin in his android try to execute my api with case task_id and id is correctly inputed, he always got

["success" => false, "message" => "File Bukan Milik Task", "status" => 400]

If he got that response, It shouldn't execute the code below, but the targeted file was deleted and file in my digital ocean space was also deleted so the code below the return was executed. And also, with case task_id and id correctly inputed, the above return was not supposed to be hit. But it was been hit and the below code also hit. In the mean time, every time i tried this api in postman, It worked normally. with output :

return ["success" => true, "message" => "Berhasil Menghapus File", "status" => 200];

This is my deleteFileTask function api code

public function deleteFileTask(Request $request)
{
    try{
        $task_id = $request->get('task_id', null);
        $id = $request->get('id', null);
        $task = Task::with('attachments')->find($task_id);
        if($task === null) return ["success" => false, "message" => "Id Task Tidak Ditemukan", "status" => 400];
        $search = $task->attachments->search(function ($item) use ($id) {
            return $item->id == $id;
        });
        if($search === false) return ["success" => false, "message" => "File Bukan Milik Task", "status" => 400];
        $fileService = new FileService;
        $delete_file_response = $fileService->deleteFile($id);
        if($delete_file_response['success']) return ["success" => true, "message" => "Berhasil Menghapus File", "status" => 200];
        else return ["success" => false, "message" => $delete_file_response['message'], "status" => 400];
    } catch(Exception $err){
        return ["success" => false, "message" => $err, "status" => 400];
    }
}

This is my deleteFile function in FileService class

public function deleteFile($id)
    {
        $file = File::find($id);
        if($file === null) return ["success" => false, "message" => "File Tidak Ditemukan"];
        $set_private = Storage::disk('do')->setVisibility($file->link, 'private');
        if(!$set_private) return ["success" => false, "message" => "File Gagal Didelete dari Space"];
        $file->delete();
        $purge_response = $this->purgeLink($file->link);
        if(!$purge_response) return ["success" => false, "message" => "Gagal Purge Data"];
        return ["success" => true];
    }

Anyone know what the cause is?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source