Feed aggregator
China Reveals a New Heavy Lift Rocket That Is a Clone of SpaceX's Starship
Read more of this story at Slashdot.
Trump Wins US Presidency For Second Time
Read more of this story at Slashdot.
CodeSOD: Uniquely Validated
There's the potential for endless installments of "programmers not understanding how UUIDs work." Frankly, I think the fact that we represent them as human readable strings is part of the problem; sure, it's readable, but conceals the fact that it's just a large integer.
Which brings us to this snippet, from Capybara James.
if (!StringUtils.hasLength(uuid) || uuid.length() != 36) { throw new RequestParameterNotFoundException(ErrorCodeCostants.UUID_MANDATORY_OR_FORMAT); }StringUtils.hasLength comes from the Spring library, and it's a simple "is not null or empty" check. So- we're testing to see if a string is null or empty, or isn't exactly 36 characters long. That tells us the input is bad, so we throw a RequestParameterNotFoundException, along with an error code.
So, as already pointed out, a UUID is just a large integer that we render as a 36 character string, and there are better ways to validate a UUID. But this also will accept any 36 character string- as long as you've got 36 characters, we'll call it a UUID. "This is valid, really valid, dumbass" is now a valid UUID.
With that in mind, I also like the bonus of it not distinguishing between whether or not the input was missing or invalid, because that'll make it real easy for users to understand why their input is getting rejected.
[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.Google CEO Forbids Political Talk After Firing 28 Over Israeli Contract Protest
Read more of this story at Slashdot.
Bitcoin Hits All-Time High
Read more of this story at Slashdot.
Korean Cinema in 'Precarious Period' Due To Netflix, Says Director Jang Joon-hwan
Read more of this story at Slashdot.
Google Asked To Remove 10 Billion 'Pirate' Search Results
Read more of this story at Slashdot.
Schneider Electric Ransomware Crew Demands $125k Paid in Baguettes
Read more of this story at Slashdot.
Amazon CEO Denies Full In-Office Mandate is 'Backdoor Layoff'
Read more of this story at Slashdot.
The Hyperloop Lives On As a 1/12th Scale Model In Switzerland
Read more of this story at Slashdot.
Interpol Disrupts Cybercrime Activity On 22,000 IP Addresses, Arrests 41
Read more of this story at Slashdot.
Russian Email Domains Target US Polling Sites with Bomb Threats, FBI Says
Read more of this story at Slashdot.
Amazon Starts Drone Deliveries In Arizona
Read more of this story at Slashdot.
World's First Wood-Paneled Satellite Launched Into Space
Read more of this story at Slashdot.
Mozilla Foundation Lays Off 30% Staff, Drops Advocacy Division
Read more of this story at Slashdot.
Oil Giant BP is Killing 18 Hydrogen Projects, Chilling the Nascent Industry
Read more of this story at Slashdot.
AMD Overtakes Intel in Datacenter Sales For First Time
Read more of this story at Slashdot.
Degradation of Land is Threat To Human Life, Saudi Government Says
Read more of this story at Slashdot.
Apple Warns Investors Future Products May Never Be as Profitable as iPhone
Read more of this story at Slashdot.
Google's Big Sleep LLM Agent Discovers Exploitable Bug In SQLite
Read more of this story at Slashdot.