`export_job.py` is not ready to merge tomorrow as it stands: a failed export looks like a success to cron, and there is no way to re-export a missed day. The three blockers are small, well-scoped fixes, and the rest can follow.

I reviewed by reading only; nothing was run. The docstring names `test_export_job.py`, but that file is not next to `export_job.py`, so I could not check the tests.

## Blockers (fix before merge)

1. **Failures are swallowed, so cron reports success.** `run()` catches every exception, logs one line and returns normally (`export_job.py:56-57`).
   - Example: the finance endpoint returns 503 at 02:00. Expected: the job exits non-zero and someone is alerted. Actual: exit code 0, no file reaches finance, and nobody knows.
   - The log line also drops the traceback.
   - Fix: use `log.exception(...)` and re-raise, or `sys.exit(1)`.

2. **A missed day can never be re-exported.** `run()` hard-codes "yesterday" (`export_job.py:47`) and takes no date argument.
   - Example: the 14 Nov run fails, so the invoices for 13 Nov are never sent; the next run only covers 14 Nov.
   - Fix: accept an optional date (CLI argument) that defaults to yesterday.

3. **The upload has no timeout.** `requests.post` at `export_job.py:42` waits forever if the endpoint hangs. The job then never finishes and never fails, and the next night's run starts alongside it.
   - Fix: add `timeout=(10, 120)` or similar.

## High

4. **Customer emails are written to the log.** `export_job.py:52` logs the full list of customer emails for every run. That is personal data in log storage, which usually has wider access and longer retention than the database. Log the count only.

5. **Test coverage is one happy path.** By the docstring, the tests cover the CSV header and one row. Nothing covers the date window in `fetch_invoices`, a failed upload, or the failure behaviour of `run()`, which is where the blockers are. Each fix above should come with a test.

## Medium

6. **The "day" depends on the server's time zone.** `date.today()` uses the cron host's local time, and the database turns the date into midnight in its own session time zone.
   - Example: host and database on UTC, finance on US Eastern. An invoice paid 13 Nov at 21:00 Eastern lands in the 14 Nov file.
   - Fix: decide the business time zone and compute the window explicitly.

7. **Invoices marked paid late are missed permanently.** If an invoice gets status `PAID` after the 02:00 run but with a `paid_at` in the already-exported day, no later run picks it up. Whether this can happen depends on how `paid_at` is set; worth confirming.

8. **Amount conversion assumes two decimal places and uses floats.** `amount_cents / 100` at `export_job.py:37`:
   - Formatting is inconsistent: 2000 becomes `20.0`, 1999 becomes `19.99`.
   - Zero-decimal currencies are wrong: JPY 500 becomes `5.0`, if such amounts are stored in the same column.
   - A NULL `amount_cents` crashes the whole export.
   - Fix: format with `Decimal`, or `f"{cents // 100}.{cents % 100:02d}"`, and handle the currency exponent if non-two-decimal currencies exist.

9. **Success messages are not logged anywhere.** No logging handler is configured, so Python drops both `log.info` lines and prints only errors to stderr. Add `logging.basicConfig(level=logging.INFO)` under `__main__`.

10. **Re-running uploads a duplicate.** A rerun overwrites the local file and posts it again. Whether finance de-duplicates by filename is unknown; this matters once blocker 2 makes reruns possible.

11. **No authentication is visible on the upload.** The request sends no token or header. If the credential is embedded in `FINANCE_UPLOAD_URL` this is fine, but confirm it.

## Low

12. **`FINANCE_UPLOAD_URL` is read at import time** (`export_job.py:16`). Importing the module in tests or tooling without that variable raises `KeyError`. Read it inside `upload()`.
13. **CSV files with customer emails accumulate in `/var/exports`** with no cleanup, and the directory is assumed to exist.
14. **Spreadsheet formula injection.** An email starting with `=`, `+`, `-` or `@` is treated as a formula if finance opens the file in Excel. Prefix such cells with `'`.
15. **A database connection failure behaves differently from other failures.** `psycopg2.connect` sits outside the `try` (`export_job.py:49`), so it crashes with a traceback while everything else is swallowed. Fixing blocker 1 makes this consistent.
16. **`fetchall()` loads every row into memory** and the file is opened without an explicit `encoding="utf-8"`. Both are fine at small volume.

## What to do before tomorrow

Fix 1, 2, 3 and 4 with tests for each; that is roughly 20 lines of code plus tests. Items 6, 7, 8 and 11 each need a quick answer from you or finance and can become follow-up tickets if the answer is "not an issue for us today".

VERDICT: NOT READY
