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

      The Double-Edged Sustainability Sword Of AI In Web Design

      August 20, 2025

      Top 12 Reasons Enterprises Choose Node.js Development Services for Scalable Growth

      August 20, 2025

      GitHub’s coding agent can now be launched from anywhere on platform using new Agents panel

      August 20, 2025

      Stop writing tests: Automate fully with Generative AI

      August 19, 2025

      I’m a diehard Pixel fan, but I’m not upgrading to the Pixel 10. Here’s why

      August 21, 2025

      Google Pixel Watch 4 vs. Samsung Galaxy Watch 8: I compared the two best Androids, and here’s the winner

      August 21, 2025

      Get a free Amazon gift card up to $300 when you preorder a new Google Pixel 10 phone – here’s how

      August 21, 2025

      Everything announced at Made by Google 2025: Pixel 10 Pro, Fold, Watch 4, and more

      August 21, 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

      Copy Errors as Markdown to Share With AI in Laravel 12.25

      August 21, 2025
      Recent

      Copy Errors as Markdown to Share With AI in Laravel 12.25

      August 21, 2025

      Deconstructing the Request Lifecycle in Sitecore Headless – Part 2: SSG and ISR Modes in Next.js

      August 20, 2025

      Susan Etlinger, AI Analyst and Industry Watcher on Building Trust

      August 20, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      TerraMaster D1 SSD Plus Review: Experience a Faster External SSD

      August 20, 2025
      Recent

      TerraMaster D1 SSD Plus Review: Experience a Faster External SSD

      August 20, 2025

      Microsoft is investigating Windows 11 KB5063878 SSD data corruption/failure issue

      August 20, 2025

      Microsoft Surface Won’t Turn On: 6 Tested Solutions to Fix

      August 20, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: I Am Not 200

    CodeSOD: I Am Not 200

    August 19, 2025

    In theory, HTTP status codes should be easy to work with. In the 100s? You’re doing some weird stuff and breaking up large requests into multiple sub-requests. 200s? It’s all good. 300s? Look over there. 400s? What the hell are you trying to do? 500s? What the hell is the server trying to do?

    This doesn’t mean people don’t endlessly find ways to make it hard. LinkedIn, for example, apparently likes to send 999s if you try and view a page without being logged in. Shopify has invented a few. Apache has added a 218 “This is Fine“. And then there’s WebDAV, which not only adds new status codes, but adds a whole bunch of new verbs to HTTP requests.

    Francesco D sends us a “clever” attempt at handling status codes.

        try {
          HttpRequest.Builder localVarRequestBuilder = {{operationId}}RequestBuilder({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}headers);
          return memberVarHttpClient.sendAsync(
              localVarRequestBuilder.build(),
              HttpResponse.BodyHandlers.ofString()).thenComposeAsync(localVarResponse -> {
                if (localVarResponse.statusCode()/ 100 != 2) {
                  return CompletableFuture.failedFuture(getApiException("{{operationId}}", localVarResponse));
                }
                {{#returnType}}
                try {
                  String responseBody = localVarResponse.body();
                  return CompletableFuture.completedFuture(
                      responseBody == null || responseBody.isBlank() ? null : memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {})
                  );
                } catch (IOException e) {
                  return CompletableFuture.failedFuture(new ApiException(e));
                }
                {{/returnType}}
                {{^returnType}}
                return CompletableFuture.completedFuture(null);
                {{/returnType}}
          });
        }
    

    Okay, before we get to the status code nonsense, I first have to whine about this templating language. I’m generally of the mind that generated code is a sign of bad abstractions, especially if we’re talking about using a text templating engine, like this. I’m fine with hygienic macros, and even C++’s templating system for code generation, because they exist within the language. But fine, that’s just my “ok boomer” opinion, so let’s get into the real meat of it, which is this line:

    localVarResponse.statusCode()/ 100 != 2
    

    “Hey,” some developer said, “since success is in the 200 range, I’ll just divide by 100, and check if it’s a 2, helpfully truncating the details.” Which is fine and good, except neither 100s nor 300s represent a true error, especially because if the local client is doing caching, a 304 tells us that we can used the cached version.

    For Francesco, treating 300s as an error created a slew of failed requests which shouldn’t have failed. It wasn’t too difficult to detect- they were at least logging the entire response- but it was frustrating, if only because it seems like someone was more interested in being clever with math than actually writing good software.

    [Advertisement]
    Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleSentry Adds Logs Support for Laravel Apps
    Next Article nbpreview – terminal viewer for Jupyter notebooks

    Related Posts

    News & Updates

    I’m a diehard Pixel fan, but I’m not upgrading to the Pixel 10. Here’s why

    August 21, 2025
    News & Updates

    Google Pixel Watch 4 vs. Samsung Galaxy Watch 8: I compared the two best Androids, and here’s the winner

    August 21, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-7552 – Dromara Northstar Remote Path Traversal Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Aflac, one of the USA’s largest insurers, is the latest to fall “under siege” to hackers

    Development

    CVE-2025-4984 – City Discover City Referential Manager Stored XSS

    Common Vulnerabilities and Exposures (CVEs)

    Key Factors to Consider Before Hiring React Native Developers for Your Project🔍

    Web Development

    Highlights

    How time-tracking apps can help you get more done – and my 4 favorite

    May 2, 2025

    You might think time tracking is just for clocking in and out, but it can…

    I don’t need 32GB of RAM, but 16GB isn’t enough anymore — 24GB is the new sweet spot, and Windows OEMs need to catch up

    April 18, 2025

    DLC for one of the best Xbox Soulslikes has now become easier to access… with a catch

    June 20, 2025

    Beats’ new chargers are optimized for iPhone and Android – and they’re more stylish than Apple’s

    April 15, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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