validate doc_type before wrapping
Merge pull request #4578 from dimagi/fetch-unwrapped

validate doc_type before wrapping