Skip to content

Diagnosing and Resolving Recursive Failures in Nirmana 2.0 - A Case Study #356

@sntshkbhr

Description

@sntshkbhr

Talk title

Diagnosing and Resolving Recursive Failures in Nirmana 2.0 - A Case Study

Short talk description

The Nirmana 2.0 debugging session began with a simple TypeError and escalated into a deep dive into persistent NoReverseMatch errors, prompting the creation of a custom link checker tool. Ironically, this "doctor" fell sick, getting trapped in recursive loops when interacting with Django's debug and template systems. The final resolution was a strategic pivot to a stable management command that tested only URL resolution, completely bypassing view execution. This robust, loop-immune script was then enhanced to generate a comprehensive, portable HTML health report with server-side charts, successfully diagnosing the application's true state.

Long talk description

Case Study Summary: Diagnosing and Resolving Recursive Failures in Nirmana 2.0
The development of the Nirmana 2.0 Proactive Maintenance module began with a seemingly routine debugging session that quickly escalated into a deep-seated architectural challenge. The initial task to fix a TypeError—caused by a mismatch between a view and its model—uncovered a series of foundational issues, including AttributeError typos and, most critically, persistent NoReverseMatch errors. These misleading errors were not caused by incorrect URL names, but by a flawed template inheritance structure and an improperly configured root urls.py, which caused the application to render outdated templates with broken links.
In response to the difficulty of manually tracing these issues, a strategic decision was made to build a proactive diagnostic tool: a "Link Checker" for the application's new Debug Centre. Ironically, this tool, personified as the "AI Doctor," immediately fell ill. It was plagued by its own set of bugs, including DisallowedHost errors from misconfigured settings and AttributeError crashes when run against an empty database.
The core crisis emerged when the script began getting stuck in inescapable infinite loops, evidenced by KeyboardInterrupt tracebacks deep within Django's core. The root cause was a "recursion paradox": the script, using Django's Test Client, would trigger a template error in a view. Because DEBUG=True, Django's error handling would activate, attempting to render its own debug page. This process re-triggered the original template error, creating a fatal loop where the framework was crashing while trying to report a crash.
The breakthrough was a strategic pivot, abandoning any tool that executed views (client.get()). A new, lightweight management command was created that only tested URL resolution (django.urls.reverse). This simple, loop-immune script worked perfectly, producing a clean "64 OK / 0 FAILED" report. This established a critical "ground truth": the application's URL configuration was perfectly healthy, proving definitively that the remaining NoReverseMatch errors were located exclusively in the template {% url %} tags.
The key learning was the necessity of isolating diagnostic tools from the system under test. The business benefits of this deep cleanse are significant, including improved code quality, reduced technical debt, and enhanced system stability. The immediate roadmap is to use the trusted resolution report to confidently fix the remaining template bugs and to integrate the stable, robust diagnostic script into the CI/CD pipeline to prevent such structural issues from recurring. This journey transformed a simple bug fix into a fundamental strengthening of the application's architecture and the development team's diagnostic capabilities.

What format do you have in mind?

Talk (20-25 minutes + Q&A)

Talk outline / Agenda

The Setup: A Routine Feature - 2 mins
The Unraveling: From Simple Bugs to a Deeper Problem - 3 mins
A Proactive Solution: The Birth of the Debug Centre - 3 mins
The Crisis: The Doctor Gets Sick - 7 mins
The Breakthrough: The Strategic Pivot - 5 mins
Q&A and Key Takeaways - 5 mins

Key takeaways

  1. Isolate Diagnostic Tools from the System Under Test.
  2. Establish a "Ground Truth" to Isolate the Real Bug.
  3. Beware the "Debugger's Paradox" and Recursive Errors.

What domain would you say your talk falls under?

Web Development

Duration (including Q&A)

30 mins

Prerequisites and preparation

Knowledge of Industrial Business Processes
Web Development
Application Integration
Django Framework

Resources and references

https://scholar.google.com/citations?user=YvsmkrIAAAAJ&hl=en

Link to slides/demos (if available)

No response

Twitter/X handle (optional)

@sntshbhr

LinkedIn profile (optional)

https://in.linkedin.com/in/dr-santosh-k-behera-7695382a?original_referer=https%3A%2F%2Fwww.google.com%2F

Profile picture URL (optional)

No response

Speaker bio

Dr. Santosh Kumar Behera has 30+ industry experience in infrastructure sector mainly in energy and transportation. He is a alumni of IIT Delhi and IIM Ahmedabad. His research interests include Productivity Management, Business Analytics. Currently he a visiting Professor with NTPC School of Business and focuses on bringing state of the art techno-managerial tool kits to managers desktops.

Availability

20/09/2025

Accessibility & special requirements

No response

Speaker checklist

  • I have read and understood the PyDelhi guidelines for submitting proposals and giving talks
  • I will make my talk accessible to all attendees and will proactively ask for any accommodations or special requirements I might need
  • I agree to share slides, code snippets, and other materials used during the talk with the community
  • I will follow PyDelhi's Code of Conduct and maintain a welcoming, inclusive environment throughout my participation
  • I understand that PyDelhi meetups are community-centric events focused on learning, knowledge sharing, and networking, and I will respect this ethos by not using this platform for self-promotion or hiring pitches during my presentation, unless explicitly invited to do so by means of a sponsorship or similar arrangement
  • If the talk is recorded by the PyDelhi team, I grant permission to release the video on PyDelhi's YouTube channel under the CC-BY-4.0 license, or a different license of my choosing if I am specifying it in my proposal or with the materials I share

Additional comments

No response

Metadata

Metadata

Labels

awaiting response from authorThis proposal needs a response from the author in order for a decision to be made on its schedulinginactiveThis proposal has not received any activity in over 60 days and hence is not in an addressable stateneeds more informationThis proposal needs more information in order for a decision to be made on its acceptanceproposalWish to present at PyDelhi? This label gets added when the "Talk Proposal" option is chosen.review in progressThis proposal is currently under review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions