Handling routes with empty parameters

I probably didn’t explain things very well and made things more complicated than necessary.

I have a page showing a list of items (the result of a query). Previously I had a simple link to a detail page, eg with a query string:
… which will of course reliably display a single record (there is no problem with query; it will never fail).

I’m using the same underlying query but adding 2 parameters, containing data from the record. So the route looks like this:
The only issue is that if a record doesn’t have an author (in this example), the query will contain an empty parameter and will fail (although the functional part - the ID - will never be empty of course). Eg
…fails (doesn’t return record 4868, whereas:
… does return the record.

I wondered if there was a way of setting up a route so that empty parameters are ignored rather than causing a query like this to fail.