`RecursionError: maximum recursion depth exceeded` in a function that walks nested JSON.
IntermediateTroubleshootingRuntime, file, subprocess & encoding errors
Answer
Likely causes → Very deep structures, or a cycle (an object referencing itself), or a missing base case.
Diagnose → Read the repeating frames in the traceback; check for self-referencing structures.
Fix → Fix the base case; for deep data rewrite as an iterative walk with an explicit stack; track visited id()s to break cycles. Raising sys.setrecursionlimit is a last resort and can segfault.
Prevent → Prefer iterative traversal for untrusted, arbitrarily deep input.
More on Runtime, file, subprocess & encoding errors
`KeyError: 'Tags'` while processing `describe_instances` output.Beginner`TypeError: can't compare offset-naive and offset-aware datetimes` in a snapshot-age check.Beginner`UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte` reading a log file.Intermediate`UnicodeEncodeError: 'ascii' codec can't encode character '✓'` when printing in a container.Intermediate`PermissionError: [Errno 13] Permission denied: '/var/log/app/report.json'`Intermediate`OSError: [Errno 24] Too many open files` in a long-running Python service.Intermediate