British mother, 29, has appendix 'wrongly removed' during Egypt holiday
Roy Keane rips into Belgium after 'rubbish' Iran draw - while former stars call out Kevin De Bruyne and co. as they risk early World Cup exit
Revealed: The 'secret' plasterer dad who walked out on Callum Turner as a toddler - and had a second family in Australia, leaving the new Mr Dua Lipa to be raised by his single mum on a tough London council estate
Rogue landlords who fail to fix problems face fines of up to £7,000
Johnny Depp's ex Amber Heard gives rare glimpse of daughter Oonagh, five, after finishing 10k race in Spain
Russell Brand says he couldn't have sexually assaulted a film worker on set of flop Arthur... because he was 'too in love' with Katy Perry to even look at another woman
'Air Miles Andy' is back: Shamed royal took a private jet for a freebie weekend away to a French stud farm hosted by a mega rich Dubai businessman... and enjoyed fine wine, boules and horse riding on the beach
Anti-woke cop calls for new rules amid storm over 'two-tier policing' following murder of teenager Henry Nowak
CodeSOD: When False is True
Lillith was integrating some new tools into an existing Ruby on Rails API. The existing API allowed you to send a dry_run flag along with the request, so that you could have the service calculate its changes without applying them.
The problem was, the new tool Lillith was integrating could send, in the body of the request, {"dry_run": false}, but the service would see it as true. Consistently.
The helper method which checked for "true" parameters looked like this:
def param_true?(param_name) param_value = params[param_name] params.key?(param_name) && (!param_value || param_value.to_s.downcase == 'true') endThe purpose of this function is to handle stringy or nil inputs gracefully. And there's one thing I can say about the function: it will always identify a true value correctly. If your false value is a string, "false", it also works. But that pesky !param_value mean that any actual boolean false value will be seen as true.
This function has been in wide use through the application. Lillith's best guess is that up to this point, no one had set the dry run flag on anything but GET requests, where everything was strings. On POST/PATCH/PUT requests, where the data was passed in the body as JSON, it got parsed into actual boolean values, and thus failed.
That's the WTF, certainly, that this function was lurking and waiting to cause this confusion. But the annoying thing in this function is that it fetches the value from the associative array, then calls params.key? to see if the key exists. That's fine, since Ruby just returns a nil if a key doesn't exist, it's just annoying. I hate to see it. This is, admittedly, more of a "me" problem, but I hate it.
How dare you stop data loss – that's not your job!
Briton tells of horror after fire ravaged tourist-filled resort - killing one woman and seeing 1,700 holidaymakers displaced
Mel Stride slams 'toxic' Reform UK as 'economic fantasists' as he sets out why Kemi Badenoch is ruling out Tories ever doing a deal with Nigel Farage
Disused Tilbury building to become new community café and pantry with reduced prices for locals
Emma Hayes pays heartfelt tribute to her late father on his 85th birthday as she reveals poignant message on her shirt during World Cup coverage
DR MAX PEMBERTON: Prostate cancer can go unnoticed for years - then it's too late. But here's the little-discussed thing every woman can do to make sure her husband catches it early
Jesy Nelson shares snap of her twin daughters' spinal braces as she urges fans to attend Parliament debate on SMA screening: 'Future SMA babies' lives don't need to look like this!'
Man 'put his foot down and tried to kill' driver in A120 road rage incident
TikTok Shows 3x More AI Slop Than YouTube, Report Finds
Read more of this story at Slashdot.