- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I just removed a logging WTF where it would write an error to log and alert the errors slack channel is a user got their logins wrong.
Admin
Frist
Admin
TRWTF is Remy mentioning this function changing the property values without mentioning it changes the property keys too, which is even worse. Now you might get duplicate keys!
Admin
single line? regexes!
Admin
I guess they could have solved the newline problem by adding a \n somewhere?
Admin
at the very least split by "} {"
Admin
If they had 2 brain cells, which they don't, they could've written a parser which utilizes a json reader and stops at { right after the }. But then, if they had the aforementioned brain cells, they would've delimited it properly and there would be no need for this crap.
Admin
Right??!! I bet they didn't think of it because they couldn't figure out what to do with strings missing the {} at both ends
Admin
Actually the best solution would be to write a virtual text reader, which stops at "} {". That way strings aren't allocated for blobs and there's no need to roll your own deserializer. I'm not sure if it's possible in Python though, definitely is in .NET.
Admin
Am I missing a subtle joke here? The word "than" is misused in several places. It is really distracting. Somebody tell me the joke! :D
Admin
Someone likes the word 'than' way too much.
Admin
My suspicion is that the logger is already adding \n to each log entry - when it needs to add \r\n instead. When loaded up in text editors that are expecting \r\n, a \n will usually display as a single space.
If I am right, then this is even more of a WTF because the code can still split the log file on \n even if all of the text editors on the user's computers are expecting \r\n.
Admin
I would guess that the keys don't have spaces, so it isn't a problem, and therefore isn't worth mentioning.
Admin
Nobody puts spaces in keys! It's not enterprisey unless the keys are either 60 character CamelCase monstrosities, or short ambiguous words like "data" (which probably contain a base64 string or an XML object).
Admin
It would be funny if they had tried the "} {" method but failed because the search failed due to a \n in there. Probably nobody involved with the project had ever heard of a hex editor, much less knew what raw file data looked like.
Admin
So the company that was taken over was happy with their logging system, probably having things put in place that knew how to parse the log file, but the company that took them over didn't like it? Sounds like the standard takeover process where everything is a lie and the smaller company has to change everything.
Admin
{ "problem": "your solution does {not}{work}" }
Admin
Apart from the bit where the larger company was the one making the change to their systems and the smaller company didn't have to do a thing.
Admin
The text reader and splitting by "} {" both have the same problem that you pointed out. However text reader improves performance by preventing allocation of strings after split. The custom deserializer doesn't have this problem but it is quite a good amount of work.
Admin
What's the problem? Look like a regular Java exception to me.
Admin
First than is a common mistake, probably Remy is overworked. The second one looks like a typo.
Admin
they should have just fixed the logging
Admin
If it's a typical serialiser, it's much easier than that, as there won't be any unnecessary spaces or backslashes, so the only spaces in the JSON will be quoted; you just need to find the first space that appears after an even number of unquoted quotes. Try
.match(/([^ "]|"([^"\\]|\\.)*")+/g)
.Admin
OMFG, this is now officially the worst code I have ever seen in my life. Congratulations to the author. I'll never raise my voice to another junior again. :'(
Addendum 2019-10-18 23:33: I'll just refer them to this article and let them do the crying.
Admin
Looking for solutions to this moronic problem is how this started out in the first place. Use a delimiter, Who cares what it is, so long as its at least probabilistic unique (Please note: The newline character is not a good candidate for this, unless escaped)
Addendum 2019-10-18 23:47: Even then, I wouldn't use it. It's too easy for someone upstream to make a mistake, which lands you with a newline in a string. Have you considered using a proper logging framework?