[1.6.x] Fixed #21284 -- Prevented KeyError swallowing in fetch_command

Thanks wildfire for the report.

Backport of 3514bcb251 from master.