Symfony 22.9.2026. 2 min read

Symfony 8 Breaks the Activation Email on localhost — and Validation Passes

Since Symfony 8, Assert\Url requires a top-level domain by default, so localhost fails. The trap is not the change itself but the same rule living in two places — the first one passes, the second crashes the app with a…

Upgrade to Symfony 8, user registration on a local machine: the form passes validation, the request proceeds normally, and — 500. In the log, a validation error for a URL that passed a moment earlier. Nothing of the sort in production. A perfect recipe for an hour of staring at the wrong part of the code.

What Changed in Symfony 8

The Assert\Url constraint now requires a top-level domain by default: example.com passes, localhost does not, and neither does any host without a dot. The requireTld option existed before, but with the opposite default. The change is reasonable for production — almost no real address has a host without a domain — and perfectly invisible until you run something locally at an address like http://localhost:5173.

Why Validation Passed and the App Crashed

The first rule was on the incoming request object: the return-address field sent by the front end. I disabled requireTld there, and the form passed. But the application validated the same address again, deeper down — in the service that builds the activation email link, with its own Assert\Url call and default settings. The first check passed; the second threw an exception while sending the email, and the user got a 500 instead of a helpful message.

The Fix and the Actual Lesson

The technical fix is trivial: requireTld: false in both places. The real lesson is that the same validation rule should not live in two places with different configurations. Validation belongs at the system boundary, where data enters; there should be no surprises deep inside a service about the shape of data that has already passed validation. I removed the second check instead of fixing it.

What Else Breaks on the Way Over

The same migration also removed the add() method from the console application in favour of addCommand() — a small change that breaks every manual command registration. Both changes have something in common: they’re documented and sensible, and you only notice them when something breaks. Before a major-version upgrade, it’s worth checking the changelog and asking: “Where does my code silently rely on this default?”

A bug that shows only locally is not less serious — just more patient.

Get in touch →