Add error check for id

device_id and cache_id
are checked if they are valid.