Fix bug in get_metadata with base_dir and json discovery