Greetings dear readers!

The name’s Vasili, and I’m the tech lead at the rad Optimum Web. When I’m not busy saving the digital world, I love diving headfirst into the latest and greatest technologies, conducting epic research, and embarking on daring tech experiments

Today I would like to share a case that is interesting in my opinion, namely how ChatGPT helped me to fix a bug I’ve never seen before. The problem arose when uploading a regular file. The source code of the project was borrowed from:

https://github.com/zupzup/warp-upload-download-example. which is accompanied by a wonderful article in my opinion

So, I built the project, launched it and everything worked right away as described in the article. Then I started tweaking the project to my needs. As a beginner in Rust, I took small steps, making gradual changes to the code. Each modification felt like a triumph as I navigated through the intricacies of the language, learning and growing with each line of code I crafted.

Everything worked great until one day the application in the container stopped accepting files, while in the jetBrains IDE everything compiled and worked as it should, which immediately suggested that I had broken something and maybe something in the Dockerfile or some container settings .

The error looked like this: reading file error: Tried to poll data from the not last Part

 

 

docker logs container output

 

However it worked well from IDE

 

Run app from IDE

 

After analysing the Dockerfile, I did not find anything suspicious, a search in Google also
did not help. Well, I compiled a prompt and fed it into ChatGPT.

Here’s what ChatGPT came up with:

 

rust warp tried to poll data from the not last part

 

OK.. wow.. quite interesting. 🤓 It turns out that a simple for loop bypass is not suitable in this particular case ?
I immediately asked to generate a code example that implements such functionality.

 

rust warp chatgpt response

Unfortunately, the proposed code did not work and gave compilation errors after several attempts to regenerate the function. After clarifying the request, the chat gave the following example

 

warp::multipart::FormData example

 

Okay…. Now it looks much better. I revised the existing code in detail and began to change some of its parts, and here’s what I came up with:

 

 

The entire file can be found here:

I checked the file upload from the terminal and everything worked again  🚀

curl -X POST http://localhost:8080/upload --header 'Content-Type: multipart/form-data' --form 'file=@img/partners/softlayer.jpg'

{"status":"200 OK","filename":"92eafc89-f248-49ba-b37c-e700fa3c5d78.jpg"}

 

The idle function looked like this

 

 

I contemplated deeply as I delicately removed my glasses, feeling the weight of my thoughts pressing against my mind. With a gentle sweep of a dry cloth, I cleared the lenses of any smudges, restoring their pristine clarity.

Your feedback and comments on this issue are warmly welcomed and highly appreciated. Feel free to share your thoughts, insights, and suggestions !

About the Author: Vasili Pascal

Dev Team Lead @ TryDirect && Software Engineer @ Optimum Web

Share This Post, Choose Your Platform!

Request a Consultation