error.md 6.2 KB

Error Operation

Purpose: Add recurring errors to knowledge base with deduplication

Last Updated: 2026-01-06


When to Use

  • Encountered same error multiple times
  • Want to document solution for team
  • Building error knowledge base
  • Preventing repeated debugging

6-Stage Workflow

Stage 1: Search Existing

Action: Search for similar/related errors

Process:

  1. Search error message across all errors/ files
  2. Find similar errors (fuzzy matching)
  3. Find related errors (same category)

Format:

Searching for: "Cannot read property 'map' of undefined"

Found 1 similar error:
  ๐Ÿ“„ development/errors/react-errors.md (Line 45)
     ## Error: Cannot read property 'X' of undefined
     Covers: General undefined property access
     Frequency: common

Found 2 related errors:
  ๐Ÿ“„ development/errors/react-errors.md
     ## Error: Cannot read property 'length' of undefined
     ## Error: Undefined is not an object

Stage 2: Check Duplication (APPROVAL REQUIRED)

Action: Present deduplication options

Format:

Options:
  [A] Add as new error to react-errors.md
      (Specific case: 'map' on undefined array)
  
  [B] Update existing 'Cannot read property X' error
      (Add 'map' as common example)
  
  [C] Skip (already covered sufficiently)

Which framework/category?
  [1] React (react-errors.md)
  [2] JavaScript (js-errors.md)
  [3] General (common-errors.md)
  [4] Create new: ___

Select option + category (e.g., 'B 1'):

Validation: MUST wait for user input


Stage 3: Preview (APPROVAL REQUIRED)

Action: Show full error entry before adding

Format:

Would update development/errors/react-errors.md:

Current (Line 45):
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
## Error: Cannot read property 'X' of undefined

**Symptom**:

TypeError: Cannot read property 'X' of undefined


**Cause**: Attempting to access property on undefined/null object.

**Solution**:
1. Add null check
2. Use optional chaining (?.)
3. Provide default value

**Code**:
```jsx
// โŒ Before
const value = obj.property

// โœ… After
const value = obj?.property ?? 'default'

Prevention: Always validate data exists Frequency: common Reference: [Link] โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

Proposed update: โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

Error: Cannot read property 'X' of undefined

Symptom:

TypeError: Cannot read property 'X' of undefined
TypeError: Cannot read property 'map' of undefined  โ† NEW
TypeError: Cannot read property 'length' of undefined  โ† NEW

Cause: Attempting to access property on undefined/null object. Common with array methods (map, filter) when data hasn't loaded. โ† NEW

Solution:

  1. Add null check
  2. Use optional chaining (?.)
  3. Provide default value (especially for arrays) โ† UPDATED

Code:

// โŒ Before
const value = obj.property
const items = data.map(item => item.name)  โ† NEW

// โœ… After
const value = obj?.property ?? 'default'
const items = (data || []).map(item => item.name)  โ† NEW

Prevention: Always validate data exists. For arrays, provide empty array default. โ† UPDATED Frequency: common Reference: [Link] โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

File size: 98 lines โ†’ 105 lines (under 150 limit โœ“)

Approve? (yes/no/edit):


**Edit mode**: Allow modification before adding

**Validation**: MUST get approval before proceeding

---

### Stage 4: Add/Update
**Action**: Add or update error entry

**Process**:
1. Add/update error in target file
2. Follow error template format
3. Maintain file size <150 lines
4. Update "Last Updated" date

**Template Format**:
```markdown
## Error: {Name}

**Symptom**: [Error message]
**Cause**: [Why - 1-2 sentences]
**Solution**: [Steps]
**Code**: [Before/After example]
**Prevention**: [How to avoid]
**Frequency**: common/occasional/rare
**Reference**: [Link]

Stage 5: Update Navigation

Action: Update README.md and add cross-references

Process:

  1. Update README.md if new file created
  2. Add cross-references to related errors
  3. Link from related concepts/examples

Stage 6: Report

Action: Show results

Format:

โœ… Added error to {category}/errors/{file}.md
๐Ÿ”— Cross-referenced with X related errors
๐Ÿ“Š Updated README.md (if needed)

Changes:
  - Updated existing error entry
  - Added 'map' and 'length' examples
  - File size: 105 lines (under 150 limit)

Deduplication Strategy

Similar Errors

Same root cause, different manifestations โ†’ Update existing to include new examples

Related Errors

Different causes, same category โ†’ Cross-reference between errors

Duplicate Errors

Exact same error already documented โ†’ Skip (already covered)

New Errors

Unique error not yet documented โ†’ Add as new error entry


Error Grouping

Group errors by framework/topic in single file:

  • react-errors.md - All React errors
  • nextjs-errors.md - All Next.js errors
  • auth-errors.md - All authentication errors

Don't create: One file per error (too granular)


Examples

Add New Error

/context error for "hooks can only be called inside components"

Add Common Error

/context error for "Cannot read property 'map' of undefined"

Add Framework Error

/context error for "Hydration failed in Next.js"

Success Criteria

  • Searched for similar errors?
  • Deduplication options presented?
  • Preview shown?
  • User approved?
  • Error follows template format?
  • File size <150 lines?
  • Cross-references added?
  • README.md updated (if new file)?

Related

  • standards/templates.md - Error template format
  • guides/workflows.md - Interactive examples