Bug 45008 - unpackaged `core` files
Summary: unpackaged `core` files
Status: RESOLVED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: python3-module-jsonschema (show other bugs)
Version: unstable
Hardware: x86_64 Linux
: P5 normal
Assignee: Stanislav Levin
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-23 18:26 MSK by Stanislav Levin
Modified: 2023-01-23 19:49 MSK (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Levin 2023-01-23 18:26:26 MSK
The following code doesn't work in *network-isolated environment* as of `jsonschema` 4.17.1-alt1:

```python                                                                        
from jsonschema import validate                                                  
                                                                                 
schema = {                                                                       
    "type": "object",                                                            
    "properties": {                                                              
        "email": {"type": "string"},                                             
    },                                                                           
}                                                                                
                                                                                 
validate({"email": "foo@bar.com"}, schema)                                       
```                                                                              

```console                                                         
[user@host dir]$ python3 ~/test.py                                               
Traceback (most recent call last):                                               
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 909, in resolve_from_url
    document = self.store[url]                                                   
  File "/usr/lib/python3/site-packages/jsonschema/_utils.py", line 28, in __getitem__
    return self.store[self.normalize(uri)]                                       
KeyError: 'https://json-schema.org/draft/2020-12/meta/core'                      

...
            
Traceback (most recent call last):                                               
  File "/dir/test.py", line 10, in <module>                                     
    validate({"email": "foo@bar.com"}, schema)                                   
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 1117, in validate
    cls.check_schema(schema)                                                     
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 230, in check_schema
    for error in validator.iter_errors(schema):                                  
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 288, in iter_errors
    for error in errors:                                                         
  File "/usr/lib/python3/site-packages/jsonschema/_validators.py", line 362, in allOf
    yield from validator.descend(instance, subschema, schema_path=index)         
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 305, in descend
    for error in self.evolve(schema=schema).iter_errors(instance):               
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 288, in iter_errors
    for error in errors:                                                         
  File "/usr/lib/python3/site-packages/jsonschema/_validators.py", line 294, in ref
    scope, resolved = validator.resolver.resolve(ref)                            
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 898, in resolve
    return url, self._remote_cache(url)                                          
  File "/usr/lib/python3/site-packages/jsonschema/validators.py", line 914, in resolve_from_url
    raise exceptions.RefResolutionError(exc)                                     
jsonschema.exceptions.RefResolutionError: HTTPSConnectionPool(host='json-schema.org', port=443): Max retries exceeded with url: /draft/2020-12/meta/core (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f427cf7ce50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
```

```                                                                                 
(Pdb) bt                                                                         
  /dir/test.py(10)<module>()                                                    
-> validate({"email": "foo@bar.com"}, schema)                                    
  /usr/lib/python3/site-packages/jsonschema/validators.py(1119)validate()        
-> cls.check_schema(schema)                                                      
  /usr/lib/python3/site-packages/jsonschema/validators.py(227)check_schema()     
-> validator = Validator(                                                        
  <attrs generated init jsonschema.validators.create.<locals>.Validator>(5)__init__()
-> self.__attrs_post_init__()                                                    
  /usr/lib/python3/site-packages/jsonschema/validators.py(217)__attrs_post_init__()
-> self.resolver = RefResolver.from_schema(                                      
  /usr/lib/python3/site-packages/jsonschema/validators.py(774)from_schema()      
-> return cls(base_uri=id_of(schema), referrer=schema, *args, **kwargs)  # noqa: B026, E501
  /usr/lib/python3/site-packages/jsonschema/validators.py(745)__init__()         
-> self.store = _utils.URIDict(_store_schema_list())                             
 > /usr/lib/python3/site-packages/jsonschema/validators.py(109)_store_schema_list()
-> for path in version.iterdir(): 

                                               
(Pdb) pp list(version.iterdir())                                                 
[PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/validation'),
 PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/unevaluated'),
 PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/meta-data'),
 PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/format-assertion'),
 PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/format-annotation'),
 PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/format'),
 PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/content'),
 PosixPath('/usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/applicator')]
```
                                                                     
There is no `core` file.

In build logs:
```                                                               
Cleaning files in /usr/src/tmp/python3-module-jsonschema-buildroot (auto)        
removed './usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2020-12/core'
removed './usr/lib/python3/site-packages/jsonschema/schemas/vocabularies/draft2019-09/core'
```
                                                                            
/usr/lib/rpm/brp.d/008-cleanup.brp: 
```sh                                             
find .$RPM_CLEANUP_TOPDIR -type f \(    \                                        
        ...                                                                      
        -o -name core   \                                                        
        ...                                                                      
        \) -print0 |                                                             
                xargs -r0 rm -vf --
```
Comment 1 Repository Robot 2023-01-23 19:49:36 MSK
python3-module-jsonschema-4.17.3-alt2 -> sisyphus:

 Mon Jan 23 2023 Stanislav Levin <slev@altlinux> 4.17.3-alt2
 - Shipped required core files (closes: #45008).