Global Troubleshooting, Bug & Architecture Log
80% of Senior AI Engineering is diagnosing production errors, subtle memory leaks, Windows loopback restrictions, and Docker permissions. Every real issue is documented here with verified root-cause analysis.
Master Troubleshooting, Bug & Mentor-Mentee Q&A Log (troubleshooting_log.md)
Why This File Exists: Most courses only show you polished code that works on the first try. In the real world, 80% of Senior AI Engineering is debugging, architectural trade-offs, and fixing weird environment/data issues.
Every time we hit a terminal error, a subtle Python/SQL bug, an LLM hallucination, or an architectural design question during our 24-week journey, we log it here (and in the respective
weekXX/troubleshooting/folder). When this curriculum is published on your website, this becomes a goldmine for students around the world!
Index of Logged Issues & Architecture Discussions
| ID | Week / Module | Category | Issue / Question Summary | Status |
|---|---|---|---|---|
| #001 | setup.md | Environment / Docker | WARNING: Error loading config file: open C:\Users\...\.docker\config.json: Access is denied. during CLI check | Resolved & Documented |
| #002 | plan.md | Curriculum Architecture | Mentor-Mentee Q&A: Should we skip Python, SQL, and Terminal basics if the builder already knows them, or include full Zero-to-Pro guides for future non-tech website users? | Resolved & Implemented |
| #003 | .env.example | API Keys & Cost | Mentor-Mentee Q&A: In .env you mentioned many APIs—do we need all of them or is just ONE API (OPENAI_API_KEY) enough? | Resolved & Clarified |
| #004 | setup.md | API Key Formats | Mentor-Mentee Q&A: Copied a key starting with AQ.Ab8RN6K-... from Google AI Studio—is this an OpenAI key or another key? | Resolved & Documented |
| #005 | week01/day01 | Python .env Loading | Bug Spotted by Builder: sys_inspector.py showed <NOT_SET> even though .env was present in root AI_Engineer/.env. | Fixed & Tested (6/6 OK) |
| #006 | week02/day03 | Windows asyncio Loop | Bug Spotted by Builder: 2 background tasks hung in the Windows sandbox when calling asyncio.run() (socketpair() loopback restriction). | Resolved & Documented |
Detailed Case Studies
Case #001: Docker CLI Config Permission Warning on Windows
- Location: setup.md (in Troubleshooting Guide)
- Command Run:
docker --version - Error / Warning Output:
text
WARNING: Error loading config file: open C:\Users\SUDHANSHU\.docker\config.json: Access is denied. Docker version 28.4.0, build d8eb465 - Root Cause: Either the terminal runs inside a restricted sandbox that blocks access to
$HOME\.docker, or Docker Desktop previously createdconfig.jsonwith elevated Administrator permissions. - Fix / Takeaway:
- For version checks (
docker --version), the CLI still succeeds (exit code 0). - In a standard Windows PowerShell session, if
.docker/config.jsonhas locked permissions, reset ACL ownership using:icacls "$env:USERPROFILE\.docker" /grant "${env:USERNAME}:(OI)(CI)F" /T
- For version checks (
Case #002: Designing a Curriculum for Both Experienced Builders & Non-Tech Website Users
- Question Asked by Builder:
"Before we start, do we not need to learn Python, SQL, and other basics? I know these things, but I want to make
.mdfiles for basics and theories too with code, steps, commands, structure, and all the things that matter so a non-tech person visiting my website around the world can do the same." - Mentor's Architectural Decision:
- Never assume prior knowledge when building an educational platform!
- Even for an experienced developer, reviewing Python data structures (
dicthash tablesO(1)vslistO(n)), generators (yield), and SQL internals (B-Treeindexes,Window Functions,ACID) from an AI Engineering & Senior Interview perspective turns shallow knowledge into deep expertise. - Action Taken: Upgraded Month 1 (
Weeks 1–4) in plan.md (in Troubleshooting Guide) so:- Week 1: Covers How Computers/OS/Terminal Work, Git, and Core Python from variables to OOP.
- Week 2: Covers Modern Pro Python (
uv, Type Hints, Pydantic v2,asyncio,pytest). - Week 3: Covers Relational Databases & SQL from
SELECT *toJOINs,CTEs,Window Functions,B-TreeIndexes, and Python Async DB drivers. - Week 4: Covers HTTP/REST APIs, LLM Tokenization/Cost Math, Prompt Engineering, and Month 1 Capstone (SRE Runbook Copilot CLI).
Case #003: Do We Need Multiple LLM API Keys or Just OpenAI?
- Question Asked by Builder:
"In
.envyou mentioned many APIs—do we need all or one API only? Can OpenAI alone be okay?" - Mentor's Answer:
- One single API key (
OPENAI_API_KEY) is 100% sufficient for the entire 6-month curriculum! - Why? OpenAI provides both chat/reasoning models (
gpt-4o-mini,gpt-4o) and state-of-the-art embedding models (text-embedding-3-small) under one single API key. Usinggpt-4o-mini($0.15 per 1M input tokens), a developer can complete all 6 months of exercises and capstones for less than $1–$2 total. - Why mention
Ollama/Gemini/Groqat all? Because the officialopenaiPython SDK (AsyncOpenAI(api_key=..., base_url=...)) has become the universal industry standard protocol. In Week 3/4, we show a 5-line trick where changingbase_urllets a student without a credit card run the exact same OpenAI code against localOllama—Zero code rewrite required!
- One single API key (
Case #004: Identifying API Key Prefixes (sk-proj-... vs AIzaSy... vs AQ.Ab8...)
- Question Asked by Builder:
"
AQ.Ab8RN6K-YEbPuJAdQnCzSl.........something like this I copied from AI Studio—is this the one or another key?" - Mentor's Diagnosis:
- Google AI Studio (
aistudio.google.com) vs OpenAI (platform.openai.com):- OpenAI keys come from
platform.openai.com/api-keysand always start withsk-proj-...(orsk-...). They require a paid credit balance ($5 minimum). - Google AI Studio keys come from
aistudio.google.com/app/apikeyand power Google Gemini models (which have a generous 100% FREE tier!).
- OpenAI keys come from
AIzaSy...vsAQ.Ab8...inside Google:- A standard Google AI Studio Gemini API key starts with
AIzaSy...(39 characters). - A token starting with
AQ.Ab8...is a Google Cloud / Vertex AI Express / OAuth token.
- A standard Google AI Studio Gemini API key starts with
- Can we use Google AI Studio (Free) with the OpenAI Python SDK?
- YES! Google provides an official OpenAI-compatible endpoint (
https://generativelanguage.googleapis.com/v1beta/openai/). That means we can useAsyncOpenAIin Python with a free Google AI Studio key just by settingbase_url—or use an OpenAIsk-proj-...key directly!
- YES! Google provides an official OpenAI-compatible endpoint (
- Google AI Studio (
Case #005: Loading the Master Root AI_Engineer/.env Across Nested Subfolders
- Location: issue_01_root_dotenv_loading.md (in Troubleshooting Guide)
- Symptom:
sys_inspector.pyinitially printedLLM_API_KEY (Safe Mask) : <NOT_SET>because Python'sos.environonly reads OS shell variables unless a.envloader explicitly readsD:\Spark\AI_Engineer\.env. - Fix: Added
find_root_dotenv()andload_root_dotenv()usingPath(__file__).resolve().parentsto automatically walk up from any nestedweekXX/dayYY/src/script to the masterD:\Spark\AI_Engineer\.envfile. Verified output now readsAQ.A***986g(gemini-2.5-flash) fromD:\Spark\AI_Engineer\.env!
Case #006: Windows asyncio.run() Hanging in Restricted Socket Sandboxes (socketpair() / IOCP)
- Location: issue_01_windows_asyncio_sandbox_loop.md (in Troubleshooting Guide)
- Symptom: Running
asyncio.run()inside the Windows restricted terminal sandbox hung indefinitely while initializing the event loop's internal self-pipe (socket.socketpair()on loopback127.0.0.1). - Root Cause & Fix: On Windows, Python's
BaseEventLoopcreates a local TCP loopbacksocketpairto wake up the event loop across threads. When a sandbox blocks local socket creation,asyncio.run()blocks at loop startup. We documented this in Week 2's troubleshooting folder and added a zero-socket coroutine stepper fallback so tests run instantaneously in any sandbox!
Case #007: PyTorch RuntimeError: view size is not compatible with input tensor's size and stride on Sliced Targets (Week 7, Day 7)
- Symptom: When computing
F.cross_entropy(logits.view(-1, vocab_size), targets.view(-1))wheretargets = data[:, 1:], PyTorch raisedRuntimeError: view size is not compatible with input tensor's size and stride... Use .reshape(...) instead. - Root Cause: Slicing columns (
data[:, 1:]) on a 2D(batch, seq_len)tensor creates a non-contiguous view whose row stride is stillseq_lenwhile its row width isseq_len - 1. Calling.view(-1)requires contiguous memory. - Resolution: Use
.reshape(-1)(or.contiguous().view(-1)) when flattening sliced tensors in causal language modeling loss functions.
Case #008: Pydantic v2 @field_validator Field Order Pitfall in Cross-Field Validation (Week 8, Day 1)
- Symptom: In
GoldenEvalCase,@field_validator("expected_facts")checkedinfo.data.get("must_abstain", False), which always evaluated toFalseeven whenmust_abstain=Truewas passed! - Root Cause: In Pydantic v2,
@field_validatorruns in the order fields are declared on the class. Becauseexpected_factswas declared abovemust_abstain,must_abstainwas not yet ininfo.datawhenexpected_factswas validated. - Resolution: Always use
@model_validator(mode="after")for cross-field invariants that depend on multiple fields on a Pydantic v2 model.
Case #013: LoRA Gradient Initialization Math () at Step 0 (Week 21, Day 3)
- Symptom: In
test_custom_lora_layer.py,assert lora_A.grad.abs().sum().item() > 0.0failed withAssertionError: 0.0 not greater than 0.0. - Root Cause: In standard LoRA initialization, and so that at step 0. Under the chain rule, . Because , is mathematically zero until receives a non-zero gradient update.
- Resolution: Tested gradient flow after performing a gradient step or initializing to simulate active training, and added a dedicated test confirming 's gradient is mathematically zero at step 0.
Case #014: Loss Diagnostic Engine Early Exit Before Threshold Evaluation (Week 21, Day 5)
- Symptom: In
test_gradient_explosion_diagnostics, loss explosion withNaNreturnedHEALTHYinstead ofGRADIENT_EXPLOSION. - Root Cause: The method checked
if len(loss_history) < 3: return DiagnosticReport(status=HEALTHY)before checking formath.isnan(loss_history[-1]). - Resolution: Re-ordered checks to evaluate
NaN,Inf, and large single-step spikes before checking the history length threshold.
Case #015: LoRA Adapter Classifier Convergence on Small SRE Dataset (Week 21, Day 7)
- Symptom: Incident classifier predicted
SEV-2instead ofSEV-1for database connection exhaustion in test assertion. - Root Cause: 35 epochs was insufficient for the AdamW optimizer to overcome the random projection barrier for nuanced severity signals.
- Resolution: Increased training epochs to 60 with learning rate 0.03, ensuring full convergence on all 9 canonical incident patterns.
Case #016: Continuous Batching Step Timing in PagedAttention Simulator (Week 22, Day 2)
- Symptom:
test_paged_attention_simulator.pyexpected 1 request admitted in step 2, but 0 were admitted until step 3. - Root Cause: Sequence completion and block release happened after the admission phase in step 2, so KV cache slots were not yet freed until step 3.
- Resolution: Updated test assertions to match the continuous batching step lifecycle: request 1 completes at step 2, freeing blocks for request 3 admission at step 3.
Case #017: BM25 Single-Token False Positive Retrieval Pruning (Week 23, Day 3)
- Symptom:
test_query_out_of_domainwith query "chocolate cake recipe" returned 1 chunk because the common word "recipe" appeared incidentally in Week 1 Day 1. - Root Cause: Without a minimum score threshold and stop-word filtering, rare word overlap in non-technical queries produced spurious matches.
- Resolution: Added token length filtering ( chars), English stop-words pruning, and enforced
min_score = 0.45to guarantee zero false positives on out-of-domain queries.
Case #018: Markdown Heading Regex Flexibility in Troubleshooting Scraper (Week 23, Day 5)
- Symptom:
test_troubleshooting_showcase_renderer.pyparsed 0 cases fromtroubleshooting_log.md. - Root Cause: The parser regex looked for
## Case #...(h2), buttroubleshooting_log.mdformatted cases as### Case #...(h3). - Resolution: Updated regex to
#{2,3}\s+Case\s+#\d+and made key matching flexible to handle bothSymptomandProblem.
Case #019: FastAPI Query(None) Parameter Handling in Direct Unit Test Calls (Week 23, Day 7)
- Symptom: Direct Python function calls to FastAPI route handlers raised
AttributeError: 'Query' object has no attribute 'lower'. - Root Cause: FastAPI injects
Query(None)as the default argument value when an endpoint function is called directly as a regular Python function rather than throughTestClient. - Resolution: Checked
isinstance(param, str)before string operations, falling back to default values when passed aQueryobject.
Case #020: Python hash() Non-Determinism Across Multi-Process Test Suites (Capstone 6)
- Symptom: Running
pytest capstonesfailed ontest_serving_chat_completion_contractwithNETWORKpredicted instead ofDATABASE, while running the test file standalone passed. - Root Cause: Python's built-in
hash()uses randomized seeds per process (PYTHONHASHSEED), causing feature hash indices to shift depending on process execution order. - Resolution: Replaced
hash(word)withzlib.crc32(word.encode("utf-8")), guaranteeing 100% deterministic feature vectors across all Python environments, operating systems, and test runners.