<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prajwal M</title>
    <description>The latest articles on DEV Community by Prajwal M (@glitch-guy0).</description>
    <link>https://dev.to/glitch-guy0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2032624%2F0a2f4f0f-0f57-4887-aef5-527f58f29fc2.png</url>
      <title>DEV Community: Prajwal M</title>
      <link>https://dev.to/glitch-guy0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/glitch-guy0"/>
    <language>en</language>
    <item>
      <title>Help Needed: Type Hint for wrapper class in python</title>
      <dc:creator>Prajwal M</dc:creator>
      <pubDate>Sat, 07 Jun 2025 16:39:53 +0000</pubDate>
      <link>https://dev.to/glitch-guy0/help-needed-type-hint-for-wrapper-class-in-python-1069</link>
      <guid>https://dev.to/glitch-guy0/help-needed-type-hint-for-wrapper-class-in-python-1069</guid>
      <description>&lt;blockquote&gt;
&lt;br&gt;
&lt;p&gt;Help! Why don't I get any type hints here?&lt;a href="https://twitter.com/hashtag/pythonlearning?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#pythonlearning&lt;/a&gt; &lt;a href="https://t.co/rLsgvCk0qb" rel="noopener noreferrer"&gt;pic.twitter.com/rLsgvCk0qb&lt;/a&gt;&lt;/p&gt;— Prajwal M (&lt;a class="mentioned-user" href="https://dev.to/glitch_guy0"&gt;@glitch_guy0&lt;/a&gt;) &lt;a href="https://twitter.com/Glitch_guy0/status/1931390461987766428?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;June 7, 2025&lt;/a&gt;&lt;br&gt;
&lt;/blockquote&gt; 

</description>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>🧠 From Chaos to Clarity: How I Designed a Structured Logging System for My Application</title>
      <dc:creator>Prajwal M</dc:creator>
      <pubDate>Sun, 01 Jun 2025 15:12:11 +0000</pubDate>
      <link>https://dev.to/glitch-guy0/from-chaos-to-clarity-how-i-designed-a-structured-logging-system-for-my-application-3mgo</link>
      <guid>https://dev.to/glitch-guy0/from-chaos-to-clarity-how-i-designed-a-structured-logging-system-for-my-application-3mgo</guid>
      <description>&lt;p&gt;Logging is deceptively tricky. When I started building my app, I assumed logging would be simple — just add &lt;code&gt;logger.info()&lt;/code&gt; or &lt;code&gt;logger.error()&lt;/code&gt; where needed. But as the app grew, so did the problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inconsistent logs from different layers
&lt;/li&gt;
&lt;li&gt;Inability to trace what failed and why
&lt;/li&gt;
&lt;li&gt;Unstructured logs that Fluent Bit couldn’t reliably parse
&lt;/li&gt;
&lt;li&gt;Missing context (like response time, request ID) in error logs
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I had questions. A lot of them. Here's how I answered them — and built a logging system that’s clean, structured, and future-ready.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤯 1. My First Realization: Logging Is Closely Tied to Exceptions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Doubt&lt;/strong&gt;: &lt;em&gt;“Logging needs all details at the end (status code, time taken, etc.), but most of those are only known at the response stage. Should I log in request and response both?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ Logging once — at the response/finalization stage — makes more sense. You get the complete picture: time taken, status code, route, etc.&lt;br&gt;&lt;br&gt;
❌ Logging both request and response separately introduces duplication and inconsistency.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🔍 2. Then I Asked: How Do I Get Debug Details from Inside the Library?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Doubt&lt;/strong&gt;: &lt;em&gt;“If I log inside the library, I miss outer context like time taken. But if I don't log there, I lose debug info.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Insight&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I realized &lt;strong&gt;exceptions are the bridge&lt;/strong&gt; — I can raise exceptions from deep inside the code, carrying debug metadata with them. Then, at the top-level (e.g., middleware), I catch and log the whole thing.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🏗️ 3. My First Design Attempt: Logging + Exception Carrying Details
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;details&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;details&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;details&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 Now I could raise exceptions &lt;strong&gt;with structured metadata&lt;/strong&gt;. I made sure every exception had a &lt;code&gt;level&lt;/code&gt; and &lt;code&gt;details&lt;/code&gt; dict — which the logger could later use.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📤 4. I Wanted JSON Logs for Fluent Bit
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Doubt&lt;/strong&gt;: &lt;em&gt;“How do I send structured logs to Fluent Bit, and will all logs have the same JSON format?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I used Python's &lt;code&gt;logging.config.dictConfig()&lt;/code&gt; with a JSON formatter (e.g., &lt;code&gt;json-log-formatter&lt;/code&gt; or &lt;code&gt;structlog&lt;/code&gt;). Now every log has fields like &lt;code&gt;level&lt;/code&gt;, &lt;code&gt;message&lt;/code&gt;, &lt;code&gt;request_id&lt;/code&gt;, &lt;code&gt;time_taken&lt;/code&gt;, etc.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧪 5. Then I Faced: Should Exceptions Decide Log Level?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Doubt&lt;/strong&gt;: &lt;em&gt;“Wait, does the exception decide if this is &lt;code&gt;info&lt;/code&gt;, &lt;code&gt;debug&lt;/code&gt;, or &lt;code&gt;error&lt;/code&gt;? Or does the logger?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ I let exceptions carry the &lt;strong&gt;log level as an enum&lt;/strong&gt; (&lt;code&gt;DEBUG&lt;/code&gt;, &lt;code&gt;INFO&lt;/code&gt;, &lt;code&gt;ERROR&lt;/code&gt;, etc.).&lt;br&gt;&lt;br&gt;
Then my logger dynamically calls &lt;code&gt;logger.debug()&lt;/code&gt;, &lt;code&gt;logger.info()&lt;/code&gt;, etc. based on that.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧵 6. Then the Real Design Emerged: Middleware-Level Logging
&lt;/h2&gt;

&lt;p&gt;I moved all logging to the final response handler:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If there’s no exception, log &lt;code&gt;INFO&lt;/code&gt; with full context (&lt;code&gt;status&lt;/code&gt;, &lt;code&gt;duration&lt;/code&gt;, etc.)&lt;/li&gt;
&lt;li&gt;If there's a custom exception, log using its &lt;code&gt;level&lt;/code&gt; and &lt;code&gt;details&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If it's unhandled, log as &lt;code&gt;ERROR&lt;/code&gt; with traceback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example final logger:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;log_exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request_context&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AppException&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;extra&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;details&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;request_context&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Unhandled exception&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exc_info&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extra&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;request_context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🛑 7. I Also Asked: What About &lt;code&gt;DEBUG&lt;/code&gt; Logs?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Doubt&lt;/strong&gt;: &lt;em&gt;“Do debug logs bubble up to middleware too?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ If debug details are important, I attach them as &lt;code&gt;details&lt;/code&gt; in exceptions.&lt;br&gt;&lt;br&gt;
🚫 I don’t emit low-level debug logs directly — instead, I raise them with exceptions if they matter for observability.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 8. I Realized: Logs and Exceptions Are Loosely Coupled, But Work Together
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Insight&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Exceptions &lt;strong&gt;carry structured data&lt;/strong&gt;, but they don't log themselves. The logger does that, at a single point, using info from the exception.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I even thought about creating a single field like &lt;code&gt;log_level&lt;/code&gt; and one &lt;code&gt;details&lt;/code&gt; dict — now the logger only looks at two fields, making it future-proof and decoupled.&lt;/p&gt;




&lt;h2&gt;
  
  
  💥 9. Final Problem: FastAPI’s &lt;code&gt;HTTPException&lt;/code&gt; Doesn’t Work for This
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Doubt&lt;/strong&gt;: &lt;em&gt;“I'm using FastAPI. Should I subclass &lt;code&gt;HTTPException&lt;/code&gt; or replace it?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ I wrapped &lt;code&gt;HTTPException&lt;/code&gt; into a custom &lt;code&gt;LoggedException&lt;/code&gt;, adding &lt;code&gt;level&lt;/code&gt; and &lt;code&gt;details&lt;/code&gt;&lt;br&gt;&lt;br&gt;
✅ Middleware logs and re-raises it as usual&lt;br&gt;&lt;br&gt;
🚫 I never log inside business logic — I only raise with metadata&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📦 Final Architecture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lib code
│
├── raises AppException("user not found", level="info", details={...})
│
controller
│
└── catches exception
    └── logs once with log level and details (JSON)
    └── returns response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🛠 Tools I Considered or Used
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;logging&lt;/code&gt; + &lt;code&gt;dictConfig&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Core logger setup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;json-log-formatter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;JSON formatter for structured logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;structlog&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;More advanced context-based structured logging&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;contextvars&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Track request-specific info like trace_id&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Fluent Bit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ship logs to log storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Elasticsearch&lt;/code&gt;, &lt;code&gt;Loki&lt;/code&gt;, &lt;code&gt;Sentry&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Log &amp;amp; error analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🧵 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Raise structured exceptions&lt;/strong&gt; with log metadata
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log once&lt;/strong&gt;, centrally, with all context (request ID, time taken, etc.)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use JSON format&lt;/strong&gt; for compatibility with log collectors
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Let exceptions carry log level&lt;/strong&gt;, but log only at the final point
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid scattered logs&lt;/strong&gt; — treat logs as events, not prints
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;📝 Written on 2025-06-01&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Stateless Struggle: Authlib, Starlette, and My Quest for a Stateless FastAPI Authentication</title>
      <dc:creator>Prajwal M</dc:creator>
      <pubDate>Wed, 28 May 2025 15:33:24 +0000</pubDate>
      <link>https://dev.to/glitch-guy0/the-stateless-struggle-authlib-starlette-and-my-quest-for-a-stateless-fastapi-authentication-2ab</link>
      <guid>https://dev.to/glitch-guy0/the-stateless-struggle-authlib-starlette-and-my-quest-for-a-stateless-fastapi-authentication-2ab</guid>
      <description>&lt;p&gt;As I embark on building a robust and scalable API with FastAPI, authentication using OpenID Connect (OIDC) is a crucial piece of the puzzle. My initial foray into this involved exploring the well-regarded authlib library. Given its solid reputation and support for various authentication flows, it seemed like a natural starting point. However, my experience, particularly when considering its integration with Starlette (often a precursor or related ecosystem to FastAPI), has led me down a frustrating path, highlighting a seemingly inherent stateful design that clashes with my need for a purely stateless architecture.&lt;/p&gt;

&lt;p&gt;My exploration with authlib for OIDC within the Starlette context quickly revealed a fundamental dependency: session management. The library, by default, heavily relies on storing authentication state within server-side sessions. This became evident as I delved into its registration process and observed its internal use of .session to persist state. While authlib admirably handles the intricacies of the OIDC specification under the hood, this forced stateful approach presents a significant hurdle for those of us aiming for stateless APIs.&lt;/p&gt;

&lt;p&gt;The documentation, while present, often lacks the clarity needed to deviate from this default stateful behavior. It feels like the library nudges you towards session-based authentication, making the path to a stateless implementation feel like an uphill battle requiring deep dives into internal workings. This lack of explicit guidance on achieving statelessness, coupled with the inherent complexity of managing sessions in a distributed environment, becomes a significant concern.&lt;/p&gt;

&lt;p&gt;My notes reflect this growing frustration. The need to manage authentication state externally if one wishes to avoid session middleware is explicitly mentioned. This begs the question: Why does authlib's Starlette integration so strongly favor a stateful model? For applications demanding scalability and adherence to stateless API design principles, this feels like an unnecessary constraint.&lt;/p&gt;

&lt;p&gt;The desire for statelessness in modern APIs is often driven by factors like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Stateless services are inherently easier to scale horizontally as they don't rely on shared session storage.&lt;br&gt;
&lt;strong&gt;Decoupling:&lt;/strong&gt; Statelessness promotes better decoupling between the client and server.&lt;br&gt;
&lt;strong&gt;Simplified Architecture:&lt;/strong&gt; Removing the complexities of session management can lead to a cleaner and more maintainable architecture.&lt;/p&gt;

&lt;p&gt;While authlib undoubtedly provides a powerful abstraction over authentication protocols, its seemingly rigid stance on session management within the Starlette ecosystem creates a significant impedance mismatch for developers targeting stateless FastAPI applications. The effort required to circumvent this default behavior and implement a truly stateless solution using authlib feels excessive, potentially outweighing the benefits of the library itself.&lt;/p&gt;

&lt;p&gt;This journey has led me to question whether authlib in this context is the most suitable tool for my specific needs. The lack of straightforward guidance on stateless implementation, the forced reliance on sessions, and the need to potentially wrestle with internal logic to achieve a stateless design all point towards a potential mismatch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My point is clear:&lt;/strong&gt; authlib's strong coupling with session management in its Starlette integration presents a significant challenge for developers aiming for stateless APIs, particularly those building with FastAPI. While the library excels in handling authentication protocols, its default stateful nature necessitates considerable effort to achieve a stateless architecture, potentially making it less ideal for this common API design pattern.&lt;/p&gt;

&lt;p&gt;The quest for a truly stateless authentication solution for my FastAPI application continues. Perhaps there are alternative libraries or strategies that offer a more aligned approach. The experience with authlib has been a valuable learning curve, highlighting the importance of choosing tools that align with the fundamental architectural principles of the application being built.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And a crucial question to the community:&lt;/strong&gt; If I'm misunderstanding something, or if there's a well-documented and straightforward way to achieve stateless OIDC authentication with authlib for Starlette/FastAPI that avoids session middleware, please enlighten me! I'm eager to learn and correct my understanding. Any guidance, examples, or pointers to relevant documentation would be incredibly appreciated.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
