Factor out parse-metadata in preparation for real error-handling.