**Not ready to merge tomorrow as written.** The job reports success to cron even when the export fails, it writes every customer's email address into the logs, and the test file its docstring mentions doesn't exist. All three fixes are small (about an hour plus tests), so tomorrow is still realistic if you make them today.

I judged it against what the module's docstring promises: a nightly 02:00 cron export of yesterday's paid invoices, uploaded to finance, tested by `test_export_job.py`.

## Must fix before merge

**1. A failed export looks like a success (High).** `export_job.py:56-57` catches every exception, logs one line and returns normally. The process exits with code 0, so cron and any monitoring see a successful run.
- Example: the finance endpoint returns a 500. `raise_for_status()` raises, the `except` logs "export failed", and the exit code is 0. Finance gets no file, and nothing alerts anyone.
- Fix: log with `log.exception(...)` (which also keeps the traceback; today it's lost), then re-raise or `sys.exit(1)`.

**2. Customer emails go into the logs (High).** `export_job.py:52` logs `[row[1] for row in rows]`, which is every customer's email, every night. That is personal data sent to wherever your logs end up, and it gets bigger as volume grows.
- Fix: log only the count and the day.

**3. The promised tests don't exist (High).** The docstring (`export_job.py:3`) says the job is tested by `test_export_job.py`, but there is no such file in this directory. Even the described scope (CSV header plus one row) wouldn't cover the paths that matter. Minimum set:
- CSV formatting of amounts (see #4)
- upload failure → non-zero exit
- the date window for "yesterday"
- empty result set

Importing the module will also fail in tests unless `FINANCE_UPLOAD_URL` is set (see #7).

## Should fix (Medium)

**4. Amounts are written as floats.** `amount_cents / 100` at `export_job.py:37` gives `1000 → "10.0"` (expected `"10.00"`) and `5 → "0.05"`. It also assumes every currency has 2 decimal places: a JPY invoice of 500 is exported as `5.0` instead of `500`. If finance parses this file, use `Decimal(amount_cents) / 100` formatted as `f"{...:.2f}"`, or export `amount_cents` as-is. Also confirm whether non-2-decimal currencies can occur.

**5. The upload has no timeout.** `requests.post` at `export_job.py:42` can hang forever if the endpoint stalls. The next night's run then starts while this one still holds a database connection. Add `timeout=(5, 60)` or similar.

## Low / clean-up

6. **Success logs never appear.** Logging is never configured, so `log.info` messages are dropped. Only errors reach stderr, through Python's last-resort handler. Add `logging.basicConfig(level=logging.INFO)` under `__main__`.
7. **Settings are read at import time.** `UPLOAD_URL = os.environ[...]` at `export_job.py:16` means a plain import fails with a `KeyError` if the variable is missing. Read it inside `run()` or pass it in, which also makes the job testable.
8. **No way to re-run a specific day.** `run()` always exports "yesterday". If a night fails (see #1), you can't backfill without editing code. Accept an optional date argument.
9. **A half-written file can be left behind.** If `write_csv` fails partway, a truncated `/var/exports/invoices-<day>.csv` stays on disk, and it contains personal data. Write to a temp file and rename it, or delete it on failure.

## Speculative (worth checking, not proven)

- **Which time zone defines "yesterday"?** `date.today()` uses the server's local zone. Postgres turns the `date` parameter into midnight in the database session's time zone. If those differ from finance's definition of a day (or if `paid_at` is `timestamptz` and the server runs UTC), invoices paid near midnight land in the wrong day's file. The 02:00 run also sits inside DST transition hours in many zones.
- **Spreadsheet formula injection.** If finance opens the CSV in Excel, an email value starting with `=`, `+`, `-` or `@` would be run as a formula. This is low likelihood for email fields.
- **Empty days.** On a day with no paid invoices, the job uploads a header-only file. That's probably fine, but confirm finance expects it.

## What's fine

The query is parameterised (no SQL injection risk), the date range is half-open (`>=` / `<`), results are sorted for stable output, the connection is always closed, and `raise_for_status()` is in the right place. The structure is already split into small functions, which will make adding the tests easy.

VERDICT: NOT READY
