`PermissionError: [Errno 13] Permission denied: '/var/log/app/report.json'`
IntermediateTroubleshootingRuntime, file, subprocess & encoding errors
Answer
Likely causes → The process user cannot write there: wrong owner, non-root container user writing to a root-owned mount, read-only filesystem, or SELinux labels.
Diagnose →
id; ls -ld /var/log/app; ls -l /var/log/app/report.json
mount | grep " /var/log "
ls -Z /var/log/app # SELinux
Fix → Write to a directory the user owns (/tmp, a volume with correct fsGroup/ownership), fix ownership, or for bind mounts add :Z on SELinux hosts.
Prevent → Make output paths configurable; set Kubernetes securityContext.fsGroup for volumes.
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`OSError: [Errno 24] Too many open files` in a long-running Python service.Intermediate`subprocess.CalledProcessError: Command '['terraform', 'plan']' returned non-zero exit status 1.` with no further detail.Beginner