Day 6 Task 02 AI debugging

Task 02. Error-Fixing Helper (AI Debug Assistant)

Quickly read the many runtime error messages you meet during development with Codex AI and apply guard code.

Task 02 Task 02 Error-Fixing Helper Lab Guide

📥 Lab input

  • • day6_meeting_notes.md (meeting notes)

💾 Lab output

  • • day6_debug_solution.js

1. Story and lab background

You put up the screen and happily wrote JavaScript to fetch API data. But when you refresh the browser, the screen freezes white and the Console fills with a red error: TypeError: Cannot read properties of undefined (reading 'map'). The junior developer stares at the code dozens of times without knowing why, and searching the message online only gives answers that don't fit their situation, ending in frustration.

More than half of development is 'debugging' — finding and fixing errors. Beginners lose lots of time because they're not yet good at reading error logs, which are the clues. In this lab, you give Codex the error behavior, the error log and the running code, and it pinpoints the root location of the problem and prescribes a fix you can use right away.

2. Learning goals

  • Read error messages in the browser console and server logs and identify the type of problem.
  • Build a logical debugging habit of analyzing the cause and path (Stack Trace) of an error.
  • Apply safe Defensive Coding yourself based on AI's error analysis report.

🛠️ Follow-along lab guide

  1. Create the lab file: press the download button below and save day6_meeting_notes.md in the automation/ folder.
  2. Ask Codex to debug: send the **Codex request prompt** below in the Codex Client prompt box to ask for a diagnosis.
  3. Apply the patch: apply Codex's diagnosis, conditional guards and readable code to your local source, refresh and check that the error is gone.

Download lab materials

Codex request prompt

Task 02 Prompt
My code throws 'TypeError: Cannot read properties of undefined (reading 'map')'. Compare the provided source code day6_debug_source.js with the console error log, explain the cause (Why) at a beginner's level, and give a fixed version with guard code that fully handles this error.

4. Example output

Codex analyzes the meeting notes and outputs a normalized data entity mapping and Mermaid ERD script like below.

FileError behaviorMain causeFix
day6_debug_source.jsTypeError: Cannot read properties of undefined (reading 'map')Reading an empty value (undefined) because the data fetch is delayedOptional chaining and exception branches

5. AI use points

  • Error context analysis: infers the context of not just simple Syntax errors but also tricky runtime exceptions caused by call order or Asynchronous Flow timing.
  • Debugging process guide: doesn't just give fixed code, but explains the concept of 'why did the error happen on this line?'