Skip to content
DevMeme
6456 of 7435
Atlassian Login Gets Base URL by Throwing Error and Parsing Error Stack
WebDev Post #7079, on Aug 27, 2025 in TG

Atlassian Login Gets Base URL by Throwing Error and Parsing Error Stack

Why is this WebDev meme funny?

Level 1: Breaking Things to Find Stuff

Imagine you wanted to find out something simple, but instead of looking it up directly, you do something wild to get the answer. This meme’s scenario is like using a hammer to crack open an egg just to see what’s inside. Sure, you’ll get your egg, but you also get eggshell everywhere and it’s a pretty crazy way to do it! We find it funny because the people in charge of the “egg” (the code) chose a needlessly messy, roundabout way to solve a basic problem. It’s an over-the-top solution – kind of like creating a problem (smashing things) in order to solve a problem – and that silliness is what makes everyone laugh in disbelief.

Level 2: Throwing Errors on Purpose

Let’s break down what’s happening in this meme in simpler terms. Atlassian (the company behind tools like Jira) has some login page script that needs to figure out where its other module files are located (the “base URL” – basically the root path on the server for its scripts). Instead of having that URL readily available (say, passed in a configuration or as a variable), the code performs a little stunt: it throws an error on purpose, then catches it, and then uses a pattern match to read the error’s stack trace and fish out the URL of the running script. Sounds wild? It is. This approach is literally what “throw-catch-regex” means: throw an error, catch it, then apply a regex (regular expression) to the error’s stack text.

Here’s the sequence of steps the code is doing:

  1. Throw a new Error() intentionally in the script (causing an exception, as if something went wrong).
  2. Catch that error immediately in a catch block so the program doesn’t actually crash. Now we have an Error object to inspect.
  3. From the caught error, take its error.stack string – a stack trace, which is basically a textual list of what functions were running and which file they were in when the error was thrown.
  4. Use a Regular Expression (a pattern matching technique) on that stack string to find a URL in it – specifically the URL of the current script file. Once found, extract the base part of that URL (everything up to the file name).

So essentially, the script is discovering its own location by peeking at the error’s report. The reason an error stack trace contains the script URL is that when you throw an error, the JavaScript engine notes where that error happened (filename and line number). So by throwing an error deliberately, the code tricks the engine into telling it “Hey, an error happened in https://yourdomain.com/path/to/login.js at line 42.” From that message, they only want the https://yourdomain.com/path/to/ part (the base URL for other modules). A regex is used to parse out that part from the full text.

Now, why would anyone do this? Possibly because the code didn’t know the base URL by itself. Maybe the same login script could be hosted under different URLs (for different customers or environments), so the developers wanted it to automatically detect where it’s running from. In theory, that’s convenient – you drop in the script and it “figures out” the base path. But the way they achieved it is very unconventional. Modern JavaScript actually has simpler ways to get the current script’s URL (like document.currentScript.src in browsers, or import.meta.url in ES modules), but perhaps those weren’t available or they needed a solution that worked in older browsers. So they went with this hacky method.

For a junior developer or someone new to Frontend coding, here are some definitions and why this is frowned upon:

  • Regular Expression (regex): A sequence of characters that forms a search pattern. We use it to find or extract pieces of text. They are powerful (you can find a URL in a blob of text, for example), but they’re also infamous for being hard to read and easy to mess up. There’s a famous saying: “Use a regex to solve a problem, and now you have two problems,” highlighting that regex can introduce complexity and bugs if not careful.
  • Error Handling in JavaScript: Normally, you use throw to signal an exception (something unexpected happened), and try...catch blocks to handle errors gracefully. It’s meant for error conditions, not as a routine way to get info. Using try/catch for normal control flow (i.e., to do something like get a value) is considered a bad practice because it’s slower and makes the code harder to understand.
  • Module Loader: This is the part of a system that dynamically loads other code modules or files as needed. A “bootstrap plan” means the procedure it uses when starting up to get everything in place. Ideally, a module loader should have clean configuration (like a known base URL or path to load modules from). If it resorts to tricks, that can be a sign of poor CodeQuality or a workaround for a design limitation.
  • Base URL: Think of this as the common path prefix for where resources are loaded from. For example, if all your script files live under https://cdn.example.com/myApp/scripts/..., that’s your base URL. The loader needs this so it knows where to fetch the next files. In our case, the script is trying to deduce that automatically by seeing where it itself came from.
  • Spaghetti code: This is a term for code that is tangled and hard to follow, like a bowl of spaghetti. Throwing an error to get a URL with a regex is a bit spaghetti-like because it entangles error handling logic with configuration discovery in a confusing way. It’s not straightforward or clear at first glance why the code is doing that, which can confuse developers reading it later (imagine debugging and stumbling on throw new Error() in the middle of a login setup – you’d scratch your head).

The reaction image in the meme – a dramatic scene with one person physically threatening another – is basically a visual metaphor. It’s as if the code says, “I’m gonna cause an error (threaten the runtime) until the system gives me what I want (the script’s URL).” The emotional tone here is exaggeration for comedic effect. Developers find it funny (and a bit horrifying) because it’s such an unnecessarily aggressive way for code to get information. The guy with the wide eyes and a cigarette might represent a developer’s face when they realize what the code is doing: a mix of “OMG, this code is insane” and “I can’t believe this made it to production!”. Many of us have had that moment of discovering some weird workaround in a codebase and reacting just like that image – stunned, maybe nervously laughing, maybe wanting to facepalm so hard.

In summary, the meme is laughing at how over-engineered and fragile this solution is. Instead of a simple, reliable approach, the code uses a convoluted method that could break easily. For a newer developer, the take-away lesson is: just because you can do something in code doesn’t mean you should. Intentional errors and regex scraping might solve the immediate problem (it finds the base URL), but they introduce new ways for things to go wrong (for example, if the error message format changes or the regex doesn’t cover some case, you’ve got a bug). It’s a funny example of a real-world bug feature that reminds us to aim for cleaner solutions when possible.

Level 3: Stacktrace Interrogation

Picture a module loader so desperate for configuration that it resorts to holding the JavaScript engine at figurative knifepoint. Atlassian’s login code literally throws an exception on purpose as a way to discover its own base URL. This isn’t a clever new design pattern; it’s more like exception-oriented programming. The meme highlights an absurd hack: using a thrown error’s stack trace (intended for debugging) as an impromptu data source. Seasoned developers are wheezing at this because it’s a textbook case of technical debt and a brittle solution that’s bound to explode at 3 AM.

In normal code, you throw errors to signal something went wrong. Here, it’s done to find out something that should have been known in a cleaner way (like a config variable or a DOM property). The error.stack property is being mined with a Regular Expression to extract the script’s URL. We’re talking about parsing a stack trace string that might look like this:

// The code equivalent of threatening the stacktrace to reveal its secrets...
try {
  throw new Error();
} catch (e) {
  const stack = e.stack;
  // e.stack might contain a line like: 
  //    at Object.<anonymous> (https://my-app.example.com/static/login.js:42:7)
  const baseUrlMatch = stack.match(/(https?:\/\/.*\/)[^\/]+\.js/);
  const baseUrl = baseUrlMatch ? baseUrlMatch[1] : '';
  // baseUrl would be "https://my-app.example.com/static/" if the regex finds a match.
}

This quirky trick grabs the current script’s path from the first stack line and then strips the filename, leaving the base URL. It’s like reading tea leaves from an error message. Why is this hilarious to experienced devs? Because it’s spaghetti code at its finest, mixing error handling and string hacking for basic config. There’s an old joke: “Some people, when faced with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems.” Here we also threw an Error into the mix – so make that three problems. The code is relying on the exact formatting of an error stack, which is notoriously inconsistent across browsers and JS engines. Chrome, Firefox, Safari – each could format the stack text differently (different wording, punctuation, or order). If any tiny detail changes (browser update, new runtime, i18n differences), the regex might fail. Boom – the module loader can’t find its modules, and login breaks. This is the kind of brittle “works by accident” solution that CodeQuality linters and senior reviewers have nightmares about.

The humor is also in the overkill and irony. Atlassian, a major enterprise software company (makers of Jira, Confluence, etc.), ended up employing a hack that feels ripped from a desperate Stack Overflow answer. It’s an anti-pattern: using exceptions for flow control and regex for something configuration-driven. That’s like using a chainsaw to carve a roast – sure, it might get the job done, but everyone is left shaking their heads and ducking for cover. Experienced devs have seen similar hacks in legacy systems: maybe an ancient module loader that couldn’t know its own script URL because it was included dynamically, so a dev found this “trick” as a workaround. It’s likely a remnant of older times before modern JS features existed – for instance, today you might use document.currentScript.src or an import.meta.url in modules to get the current script URL more cleanly. But perhaps those weren’t available or convenient in Atlassian’s environment, so someone chose the “chuck an error and parse it” route. It’s clever in a hacky way, but it’s also incredibly fragile. Essentially, the code is interrogating the runtime: “Tell me where I am, or else!” – pulling data out of the engine in a way that was never intended as an API.

The meme’s reaction image underscores this madness. It shows a tense movie scene: one guy (bald, aggressive) holding another man by the collar and pressing something menacingly to his cheek. This perfectly mirrors what the code is doing: holding the JavaScript engine hostage to extract the base URL. The second character’s wide-eyed look (and the lit cigarette) is the face of a veteran engineer reading this code in disbelief, half in shock, half thinking “I need a smoke.” It’s darkly comic – on one hand, you want to laugh at how ridiculous the strategy is; on the other, you cringe knowing that if this piece of code fails, some poor developer will have a hellish bug to chase down. The BlueSky post text describes the hack in plain disbelief, and the image essentially screams, “What maniac thought this was okay?!” in meme form.

From a senior perspective, this scenario ticks all the familiar boxes of DevOps PTSD: a critical system (login) held together by a fragile regex on an error stacktrace. We’ve all seen incidents where a minor change (like a new error message format or a different deployment path) caused a domino effect. The veteran engineers reading this can easily imagine being on-call when the “Atlassian login” suddenly breaks because error.stack didn’t match the regex – a true “it’s always the one thing you never suspect” moment. And knowing corporate culture, that hack probably lingered because “it works, don’t touch it.” No Jira ticket for refactoring a working hack ever gets priority, right? So it persists, a ticking time bomb in production.

In summary, the meme is poking fun at how absurd and brittle this approach is. It highlights a gap between best practices and what sometimes happens in real-life codebases. For seasoned devs, it’s a mix of schadenfreude and sympathy: we laugh because it’s not our mess (this time), but we also feel for the engineer who had to implement or maintain this. Throw-catch-regex as a bootstrap plan is something you’d jokingly threaten to do in a late-night coding session, not actually ship to production... except, well, here we are. It’s the kind of coding horror story retold over beers, with everyone at the table groaning, “I’ve seen some bad Frontend hacks, but this one takes the cake.”

Description

A Bluesky/Mastodon post from Yuri Krupenin (@[email protected]) boosted by 'сережа' that reads: '>>Atlassian login gets the base URL for its module scripts by throwing an error and pulling out the current script's URL from error.stack with regex.' with a link to github.com/LadybirdBrow... The reaction image below shows Matthew McConaughey from True Detective lighting a cigarette with an intense, knowing expression -- the universal reaction to discovering horrifying-yet-functional enterprise code. The 'Translate' button suggests the post may have been in a different language originally

Comments

27
Anonymous ★ Top Pick Atlassian's code doesn't have bugs -- it has surprise features that throw errors on purpose so regex can parse the stack trace for metadata. This is what peak enterprise engineering looks like
  1. Anonymous ★ Top Pick

    Atlassian's code doesn't have bugs -- it has surprise features that throw errors on purpose so regex can parse the stack trace for metadata. This is what peak enterprise engineering looks like

  2. Anonymous

    Sure, we could pass a BASE_URL constant - but why spoil the fun when we can yeet an exception, grep the stack, and pray the minifier doesn’t change line numbers?

  3. Anonymous

    When you've been debugging production issues for 15 years and discover that a Fortune 500 company's authentication system works by deliberately causing exceptions to parse stack traces with regex - suddenly you understand why their Jira tickets take 30 seconds to load and why 'There is no spoon' feels less like philosophy and more like architectural documentation

  4. Anonymous

    When your module loader needs to know its own URL but you've already shipped to production without proper configuration, just throw an error, parse the stack trace with regex, and call it 'runtime introspection.' It's not a hack if it's in the Atlassian codebase - it's enterprise-grade self-discovery. Bonus points: this probably survived multiple architecture reviews and still works across browser updates, which is either a testament to JavaScript's stability or a warning sign that we've all collectively given up on doing things the 'right' way

  5. Anonymous

    Regex on stack traces: enterprise's single source of truth when env vars are too mainstream

  6. Anonymous

    If your loader discovers its base URL by throwing and regexing error.stack, you don’t have modules - you have a séance, with CSP, source maps, and browser updates as the ghosts

  7. Anonymous

    Enterprise SSO, defined: discover your base path by throwing an exception and regexing the stack - right up until Chrome tweaks the format and auth dies at 3 a.m

  8. @DerKnerd 10mo

    I kind of love the idea and hate it very much at the same time

  9. @LonelyGayTiger 10mo

    Yeah I've done this in some of my own code that had to work with other people's systems before.

  10. @deerspangle 10mo

    bsky post link: https://bsky.app/profile/yurikrupenin.bsky.social/post/3lxctpmynbs2n github issue link: https://github.com/LadybirdBrowser/ladybird/pull/5678

  11. @feralape 10mo

    This is definitely n+1 thinking, I would never throw an error unless there is something to gain from it

  12. @moosschan 10mo

    That inspired me to copy all of my databases every time I want retrieve any information from them

    1. @SamsonovAnton 10mo

      You better copy-on-write to have a perfectly "functional" immutable database, that at the same time backs itself up and supports replication natively. 🤓

      1. @deadgnom32 10mo

        btrfs?

        1. @SamsonovAnton 10mo

          Store each data record as a file. Use directories for database names and table names. Use file names for field values and indexed combinations. Create hardlinks to the same file (record) for each field name and indexed combination. 🤔

          1. @deadgnom32 10mo

            basically

          2. @a_desant 10mo

            Nah, all my homies use csv

            1. @SamsonovAnton 10mo

              But CSV is still just a file, so a filesystem is required to store it at the lower level.

              1. @RiedleroD 10mo

                csv can be anything. I can send raw CSV via http if I want

                1. @RiedleroD 10mo

                  or like, as a blob in a gameboy cartridge

                2. @SamsonovAnton 10mo

                  So you are saying we should replace btrfs with http for our revolutionary database engine? http://db.host/database/table/?name=Dev&last=Meme

                  1. @RiedleroD 10mo

                    lmao sure

              2. @ZgGPuo8dZef58K6hxxGVj3Z2 10mo

                CSV is a format *

              3. @chupasaurus 10mo

                Nothing can stop me from storing CSVs in a raw disk partition with some padding

          3. @azizhakberdiev 10mo

            of course, why not just let OS to handle search optimization

            1. @SamsonovAnton 10mo

              I'm a bit preoccupied about transactional mechanisms, though. We would need low-level control on filesystem driver for this, rather than rely on conventional higher-level API. Filesystem scaling capability is also of a concern, as storing millions of directory entries is not a typical scenario for general-purpose filesystems.

  13. @callofvoid0 10mo

    all the people with a life

Use J and K for navigation