CodeSOD: Going Crazy
For months, everything at Yusuf's company was fine. Then, suddenly, he comes in to the office to learn that overnight the log exploded with thousands of panic messages. No software changes had been pushed, no major configurations had happened- just a reboot. What had gone wrong?
This particular function was invoked as part of the application startup:
func (a *App) setupDocDBClient(ctx context.Context) error { docdbClient, err := docdb.NewClient( ctx, a.config.MongoConfig.URI, a.config.MongoConfig.Database, a.config.MongoConfig.EnableTLS, ) if err != nil { return nil } a.DocDBClient = docdbClient return nil }This is Go, which passes errors as part of the return. You can see an example where docdb.NewClient returns a client and an err object. At one point in the history of this function, it did the same thing- if connecting to the database failed, it returned an error.
But a few months earlier, an engineer changed it to swallow the error- if an error occurred, it would return nil.
As an organization, they did code reviews. Multiple people looked at this and signed off- or, more likely, multiple people clicked a button to say they'd looked at it, but hadn't.
Most of the time, there weren't any connection issues. But sometimes there were. One reboot had a flaky moment with connecting, and the error was ignored. Later on in execution, downstream modules started failing, which eventually led to a log full of panic level messages.
The change was part of a commit tagged merely: "Refactoring". Something got factored, good and hard, all right.
[Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.Man dies after serious crash between car and motorbike on M11 near Harlow
Scottie Scheffler stuns golf fans with the 'greatest shot ever' to help him win another $3.6million
Britain's most elusive conman: The luxury lifestyle led by Zambian fraudster who stole £3.5m in elaborate scam before finally being deported after 25 YEARS
Vladimir Putin's surprising lunch menu for meeting with Donald Trump is revealed - despite never getting a chance to eat it after cutting talks short
In Otter news, transcription app accused of illegally recording users’ voices
Voice transcription service Otter.ai has found itself on the wrong end of a lawsuit that claims it trains its speech recognition tech without securing permission to do so.…
Pregnant Vanessa Hudgens bares her baby bump in crop top at 'epic' EDM rave
Rare 'Upper Atmosphere Lightning' Photographed From ISS
Read more of this story at Slashdot.
This is everything I eat in a day as a gut health scientist on the Mediterranean diet
Tragic development after man poured hot coffee on a baby in Australia and then fled back to China
Truth behind viral 'world's worst psychic' Sylvia Browne from 90s talk show and her wildly wrong predictions
India's PM laments missing out on global chipmaking dominance – in 1964!
Indian prime minister Narendra Modi has celebrated the nation’s independence day by pointing out that the nation is finally becoming a global chipmaking contender – 60 years after blowing the chance to be a global leader.…
Ship crew member died after being crushed by unloading trailer at docks in Purfleet, report finds
Exact places where the A12 will be closed overnight for road maintenance works
Residents say UK's oldest city in Essex is a hidden gem, a 'must-visit'
Wayne Couzens' marital home - with hot-tub he built in the garden - hits the market: Three-bed house where killer cop lived with wife and kids is on sale for £280K
Rubbish collections are delayed because of a staff shortage... after binmen went on holiday
Outrageous! Fury at threat to increase rail fares by 5.5%
Fury as 'arch-hypocrite' Angela Rayner is selling off allotments... but not in her patch
Google's 'AI Overview' Pointed Him to a Customer Service Number. It Was a Scam
Read more of this story at Slashdot.