Add universal error checks for missing or invalid ID