Repository: conda/conda

Issue:
Add upgrade error message for unsupported repodata_version
Going back to the 4.3.x branch, add an exception that gets raised if a field `repodata_version` exists with a value that's greater than 1.
Add upgrade error message for unsupported repodata_version
Going back to the 4.3.x branch, add an exception that gets raised if a field `repodata_version` exists with a value that's greater than 1.


Discussion:

Resolving patch:
diff --git a/conda/core/subdir_data.py b/conda/core/subdir_data.py
--- a/conda/core/subdir_data.py
+++ b/conda/core/subdir_data.py
@@ -26,7 +26,7 @@
 from ..common.io import ThreadLimitedThreadPoolExecutor, as_completed
 from ..common.url import join_url, maybe_unquote
 from ..core.package_cache_data import PackageCacheData
-from ..exceptions import CondaDependencyError, CondaHTTPError, NotWritableError
+from ..exceptions import CondaDependencyError, CondaHTTPError, CondaUpgradeError, NotWritableError
 from ..gateways.connection import (ConnectionError, HTTPError, InsecureRequestWarning,
                                    InvalidSchema, SSLError)
 from ..gateways.connection.session import CondaSession
@@ -51,7 +51,8 @@
 log = getLogger(__name__)
 stderrlog = getLogger('conda.stderrlog')
 
-REPODATA_PICKLE_VERSION = 18
+REPODATA_PICKLE_VERSION = 19
+MAX_REPODATA_VERSION = 1
 REPODATA_HEADER_RE = b'"(_etag|_mod|_cache_control)":[ ]?"(.*?[^\\\\])"[,\}\s]'
 
 
@@ -146,6 +147,16 @@ def cache_path_pickle(self):
 
     def load(self):
         _internal_state = self._load()
+        if _internal_state["repodata_version"] > MAX_REPODATA_VERSION:
+            raise CondaUpgradeError(dals("""
+                The current version of conda is too old to read repodata from
+
+                    %s
+
+                (This version only supports repodata_version 1.)
+                Please update conda to use this channel.
+                """) % self.url_w_subdir)
+
         self._internal_state = _internal_state
         self._package_records = _internal_state['_package_records']
         self._package_dists = _internal_state['_package_dists']  # only needed as an optimization for conda-build  # NOQA
@@ -333,7 +344,17 @@ def _process_raw_repodata_str(self, raw_repodata_str):
             '_add_pip': add_pip,
             '_pickle_version': REPODATA_PICKLE_VERSION,
             '_schannel': schannel,
+            'repodata_version': json_obj.get('repodata_version', 0),
         }
+        if _internal_state["repodata_version"] > MAX_REPODATA_VERSION:
+            raise CondaUpgradeError(dals("""
+                The current version of conda is too old to read repodata from
+
+                    %s
+
+                (This version only supports repodata_version 1.)
+                Please update conda to use this channel.
+                """) % self.url_w_subdir)
 
         meta_in_common = {  # just need to make this once, then apply with .update()
             'arch': json_obj.get('info', {}).get('arch'),
diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py
--- a/conda/gateways/disk/read.py
+++ b/conda/gateways/disk/read.py
@@ -145,12 +145,14 @@ def _paths():
         return None
     else:
         with open(path, 'r') as f:
-            package_metadata = PackageMetadata(**json.loads(f.read()))
-            if package_metadata.package_metadata_version != 1:
+            data = json.loads(f.read())
+            if data.get('package_metadata_version') != 1:
                 raise CondaUpgradeError(dals("""
                 The current version of conda is too old to install this package. (This version
                 only supports link.json schema version 1.)  Please update conda to install
-                this package."""))
+                this package.
+                """))
+        package_metadata = PackageMetadata(**data)
         return package_metadata
 
 


Test patch: