Skip to main content

Debugging Prompts Archive

Effective prompts and solutions for debugging TradeEntry.


Bug: ModuleNotFoundError for nseeod

Symptom:

python NSEEod\downloadbhav.py
ModuleNotFoundError: No module named 'nseeod'

Root Cause: Running a script directly adds its parent folder to sys.path, not the project root.

Prompt:

When I run `python nseeod/downloadbhav.py` I get ModuleNotFoundError.
But `python -m nseeod.downloadbhav` works fine. Why?

Solution: Always invoke as a module from the backend/ directory:

cd backend
python -m nseeod.downloadbhav

Bug: AMI Files Only Generated for Last Date

Symptom: Bulk bhav download only generated AMI for the most recent date, not all downloaded dates.

Root Cause 1: has_errors flag gated the AMI generation block, so any minor error during sync blocked all AMI generation.

Root Cause 2: NSEWorkingDays() silently failed (exception swallowed), hitting a fallback that only fetched MAX(sdate).

Fix:

  1. Removed the has_errors gate.
  2. Replaced NSEWorkingDays() with a direct DB query:
    SELECT DISTINCT sdate FROM scr_nseeq_eod WHERE sdate > %s ORDER BY sdate

Bug: Race Condition in Frontend Progress

Symptom: Progress bar never updated; frontend showed "READY" even during active download.

Root Cause: BackgroundTasks runs after HTTP response; stats.json still shows old READY status when polling starts.

Fix: hasSeenRunning guard — poll silently until server writes RUNNING to stats.json, then watch for completion.


Placeholder: Add More Debug Cases

Document bugs here as you encounter and resolve them.