# 500s, but the service's CloudWatch log group shows no application errors
Services: any PHP backend · Owner: backend lead

## Symptom
Users see 500s. `/ecs/<tier>/<service>` shows nginx/php-fpm lines but no Yii exception, or a repeating
`fopen(/proc/self/fd/2)` / `failed to open stream` error on every request.

## Confirm it is this
- Look at the service's `log` component in `config/web.php` (filemst: `common/config/base.php`).
- A Yii `FileTarget` pointed at `/proc/self/fd/2` is the known-bad pattern. Under php-fpm that fd is a
  pipe, not a reopenable path, so the target throws on every request and the real error is lost.

## Fix
Use the stderr-mirroring target (`\app\components\StderrLogTarget`; filemst
`\common\components\StderrLogTarget`), which writes to `php://stderr`. awslogs ships that to
CloudWatch. This fix comes from the `fix/yii-stderr-log-target` branch; check it is on the deployed
commit (`git log --oneline -- <svc>/components/StderrLogTarget.php`).

To see the real error meanwhile, use `aws ecs execute-command` to get into the task and read
`runtime/logs/app.log`, if a FileTarget to `@runtime` is configured.

## Prevent
`REVIEW.md` and the `secure-api-review` skill flag the bad pattern. Eval case
`evals/cases/03-filetarget-proc-fd.md`.
