Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: Uniquely Validated

    CodeSOD: Uniquely Validated

    November 6, 2024

    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.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleA Complete Guide to Creating Summary Reports in Salesforce
    Next Article DELTA: A Novel AI Method that Efficiently (10x Faster) Tracks Every Pixel in 3D Space from Monocular Videos

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 16, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-47916 – Invision Community Themeeditor Remote Code Execution

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    GoldenDict-ng is an advanced dictionary lookup program

    Linux

    What if We could Universally Edit Any Two Pieces of DNA? Meet ‘Bridge Editing’ and ‘Bridge RNA’: A Modular Approach to RNA-Guided Genetic Rearrangements in Bacteria

    Development

    Node.js Now Supports TypeScript Natively: Everything You Need to Know

    Development

    TypeScript: The problem with function overloads

    Development

    Highlights

    Development

    Meet Decisional AI: An AI Agent for Financial Analysts

    August 19, 2024

    Tasks like extracting data, creating market maps, and sorting through transcripts and board packs prevent…

    Windows 11’s Microsoft 365 app is taking a new AI-first approach with Copilot

    December 21, 2024

    6 Best Free and Open Source Address Book Managers

    June 28, 2024

    Identification of Hazardous Areas for Priority Landmine Clearance: AI for Humanitarian Mine Action

    November 7, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.