?? Do not ever copy/paste to your code from Browser
John Pourdanis
???? Professional Nothing Knower | Quality Engineering in Software Industry
?? On my latest tasks regarding Testing , I had to write some API tests and I made a copy that is remarkable for writing this post.
We are trying to write some tests for an API that has an OpenAPI swagger page with the endpoints and input/output specs like the following :
? Seems familiar? I felt the same so I tried to copy and paste from this Web Page the endpoint that I want to write the tests.
First attempt to run the test and I got a 404 Not Found exception.
?? Ok lets calm down and see what's going wrong.
So what is wrong with this endpoint? After spent some hours and pair debugging with Thanasis Nikolaidis found the difference on git!
?? And I was like...
The true difference come up with an old-school tool called Notepad++ that shows ALL the characters. Even this ZWSP character!
领英推荐
After googling the ZWSP character found this : https://en.wikipedia.org/wiki/Zero-width_space
From Wikipedia, the free encyclopedia
Purpose
The zero-width space marks a potential line break without hyphenation; for hyphenated line breaks, a soft hyphen is used. The zero-width space can be used to mark word breaks in languages without visible space between words, such as Thai, Myanmar, Khmer, and Japanese.[1][2]
Unlike fixed-width spaces, in justified text that increases spacing between letters, characters adjacent to the zero-width space are spaced as if it was not present.[2]
?? After I laughed with tears, I fixed the issue and learned that I will never, ever again copy urls from a web page if I want to use them in my code.
Happy testing
Quality Engineering Consultant, Keynote-Speaker ??, curiosity-driven and test-obsessed Software-Developer, Software-Anthropologist, Oracle ACE Alumn??, Workshop-Facilitator, Knowledge-Spreader
1 年Once you know this kind of thing (zero-width characters) exist, it is easy to configure your preferred IDE to show them. Therefore I don't follow your conclusion about "never copy a URL" - the problem was not that you copy pasted, but that you had a knowledge gap (which is totally normal). The conclusion reminds me of "never use pointers" or "never use dynamic SQL" - I would rather rephrase it as "When copying URLs, remember there are things like zero-width characters". But I guess that's not as catchy ;)
???? Professional Nothing Knower | Quality Engineering in Software Industry
1 年I also found how to show those kind of characters to Visual Studio and to VS code. I think most of IDEs will have the option.
Test Automation Engineer Team Lead??Workview COG
1 年I've spent hours in the past troubleshooting an sql query that contained a Greek character...
Quality Engineering Leader | Result focused Data driven ? Delivering high Quality products with speed & style ?? Meetup, conference keynote Speaker ?? #QualityWithMillan
1 年ZWSP, nice one ??
Just another Software Engineer | MSc in Computer Science
1 年You can turn this article to a nice thriller mini movie! I was even terrified only reading this. How many hours it took you just to find this and how many times you thought about to throw the computer from the window? ??