Flaky test failure in jsonschema/validators.py
Open
@ayoubdiourin7 is already working on this.
Since Sep 14, 2026.
- Dominant language
- Python
- Stars
- 570
- Forks
- 351
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 65
Description
=================================== FAILURES ===================================
____________ test_jsone_validates[/bugbug/infra/data-pipeline.yml] _____________
self = <Registry (21 resources, 1 uncrawled)>
uri = 'https://community-tc.services.mozilla.com/schemas/queue/v1/task.json'
def get_or_retrieve(self, uri: URI) -> Retrieved[D, Resource[D]]:
"""
Get a resource from the registry, crawling or retrieving if necessary.
May involve crawling to find the given URI if it is not already known,
so the returned object is a `Retrieved` object which contains both the
resource value as well as the registry which ultimately contained it.
"""
resource = self._resources.get(uri)
if resource is not None:
return Retrieved(registry=self, value=resource)
registry = self.crawl()
resource = registry._resources.get(uri)
if resource is not None:
return Retrieved(registry=registry, value=resource)
try:
> resource = registry._retrieve(uri)
^^^^^^^^^^^^^^^^^^^^^^^
/bugbug/.venv/lib/python3.12/site-packages/referencing/_core.py:428:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/validators.py:112: in _warn_for_remote_retrieve
with urlopen(request) as response: # noqa: S310
^^^^^^^^^^^^^^^^
/usr/local/lib/python3.12/urllib/request.py:215: in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.12/urllib/request.py:521: in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.12/urllib/request.py:630: in http_response
response = self.parent.error(
/usr/local/lib/python3.12/urllib/request.py:559: in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.12/urllib/request.py:492: in _call_chain
result = func(*args)
^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib.request.HTTPDefaultErrorHandler object at 0x79bf3e03b8c0>
req = <urllib.request.Request object at 0x79bf3f509a00>
fp = <http.client.HTTPResponse object at 0x79bf3f36be50>, code = 503
msg = 'Service Unavailable'
hdrs = <http.client.HTTPMessage object at 0x79bf3f367320>
def http_error_default(self, req, fp, code, msg, hdrs):
> raise HTTPError(req.full_url, code, msg, hdrs, fp)
E urllib.error.HTTPError: HTTP Error 503: Service Unavailable
/usr/local/lib/python3.12/urllib/request.py:639: HTTPError
The above exception was the direct cause of the following exception:
self = Resolver(_base_uri='https://community-tc.services.mozilla.com/schemas/queue/v1/create-task-request.json', _registry=<Registry (21 resources, 1 uncrawled)>)
ref = 'task.json#/properties/workerType'
def lookup(self, ref: URI) -> Resolved[D]:
"""
Resolve the given reference to the resource it points to.
Raises:
`exceptions.Unresolvable`
or a subclass thereof (see below) if the reference isn't
resolvable
`exceptions.NoSuchAnchor`
if the reference is to a URI where a resource exists but
contains a plain name fragment which does not exist within
the resource
`exceptions.PointerToNowhere`
if the reference is to a URI where a resource exists but
contains a JSON pointer to a location within the resource
that does not exist
"""
if ref.startswith("#"):
uri, fragment = self._base_uri, ref[1:]
else:
uri, fragment = urldefrag(urljoin(self._base_uri, ref))
try:
> retrieved = self._registry.get_or_retrieve(uri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/bugbug/.venv/lib/python3.12/site-packages/referencing/_core.py:682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Registry (21 resources, 1 uncrawled)>
uri = 'https://community-tc.services.mozilla.com/schemas/queue/v1/task.json'
def get_or_retrieve(self, uri: URI) -> Retrieved[D, Resource[D]]:
"""
Get a resource from the registry, crawling or retrieving if necessary.
May involve crawling to find the given URI if it is not already known,
so the returned object is a `Retrieved` object which contains both the
resource value as well as the registry which ultimately contained it.
"""
resource = self._resources.get(uri)
if resource is not None:
return Retrieved(registry=self, value=resource)
registry = self.crawl()
resource = registry._resources.get(uri)
if resource is not None:
return Retrieved(registry=registry, value=resource)
try:
resource = registry._retrieve(uri)
except (
exceptions.CannotDetermineSpecification,
exceptions.NoSuchResource,
):
raise
except Exception as error:
> raise exceptions.Unretrievable(ref=uri) from error
E referencing.exceptions.Unretrievable: 'https://community-tc.services.mozilla.com/schemas/queue/v1/task.json'
/bugbug/.venv/lib/python3.12/site-packages/referencing/_core.py:435: Unretrievable
The above exception was the direct cause of the following exception:
self = Draft202012Validator(schema={'$ref': 'task.json#/p...es/workerType'}, format_checker=None)
ref = 'task.json#/properties/workerType', instance = 'batch'
def _validate_reference(self, ref, instance):
if self._ref_resolver is None:
try:
> resolved = self._resolver.lookup(ref)
^^^^^^^^^^^^^^^^^^^^^^^^^^
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/validators.py:462:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Resolver(_base_uri='https://community-tc.services.mozilla.com/schemas/queue/v1/create-task-request.json', _registry=<Registry (21 resources, 1 uncrawled)>)
ref = 'task.json#/properties/workerType'
def lookup(self, ref: URI) -> Resolved[D]:
"""
Resolve the given reference to the resource it points to.
Raises:
`exceptions.Unresolvable`
or a subclass thereof (see below) if the reference isn't
resolvable
`exceptions.NoSuchAnchor`
if the reference is to a URI where a resource exists but
contains a plain name fragment which does not exist within
the resource
`exceptions.PointerToNowhere`
if the reference is to a URI where a resource exists but
contains a JSON pointer to a location within the resource
that does not exist
"""
if ref.startswith("#"):
uri, fragment = self._base_uri, ref[1:]
else:
uri, fragment = urldefrag(urljoin(self._base_uri, ref))
try:
retrieved = self._registry.get_or_retrieve(uri)
except exceptions.NoSuchResource:
raise exceptions.Unresolvable(ref=ref) from None
except exceptions.Unretrievable as error:
> raise exceptions.Unresolvable(ref=ref) from error
E referencing.exceptions.Unresolvable: task.json#/properties/workerType
/bugbug/.venv/lib/python3.12/site-packages/referencing/_core.py:686: Unresolvable
The above exception was the direct cause of the following exception:
pipeline_file = '/bugbug/infra/data-pipeline.yml'
task_schema = {'$id': 'https://community-tc.services.mozilla.com/schemas/queue/v1/create-task-request.json#', '$schema': 'https://co...n/metaschema.json#', 'additionalProperties': False, 'description': 'Definition of a task that can be scheduled\n', ...}
payload_schema = {'$id': 'https://community-tc.services.mozilla.com/schemas/docker-worker/v1/payload.json#', '$schema': 'http://json-sc...rtifact upload type.', 'type': 'string'}}, 'required': ['type', 'path'], 'title': 'Docker Worker Artifact', ...}}, ...}
@pytest.mark.parametrize(
"pipeline_file",
(
os.path.realpath(os.path.join("infra", f))
for f in os.listdir("infra")
if f.endswith(".yml")
),
)
def test_jsone_validates(pipeline_file, task_schema, payload_schema):
responses.add_passthru("https://community-tc.services.mozilla.com/")
with open(pipeline_file, "r") as f:
yaml_content = yaml.safe_load(f.read())
result = jsone.render(yaml_content, context={"version": "42.0"})
tasks = result["tasks"]
all_ids = [task["ID"] for task in tasks]
# Make sure there are no duplicate IDs.
assert len(all_ids) == len(set(all_ids))
# Make sure all dependencies are present.
for task in tasks:
assert "dependencies" not in task or all(
dependency in all_ids for dependency in task["dependencies"]
)
for task in tasks:
if "ID" in task:
del task["ID"]
if "dependencies" in task:
del task["dependencies"]
> jsonschema.validate(instance=task, schema=task_schema)
/bugbug/tests/test_pipelines.py:71:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/validators.py:1330: in validate
error = exceptions.best_match(validator.iter_errors(instance))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/exceptions.py:479: in best_match
best = max(errors, key=key, default=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/validators.py:383: in iter_errors
for error in errors:
^^^^^^
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/_keywords.py:296: in properties
yield from validator.descend(
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/validators.py:431: in descend
for error in errors:
^^^^^^
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/_keywords.py:275: in ref
yield from validator._validate_reference(ref=ref, instance=instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Draft202012Validator(schema={'$ref': 'task.json#/p...es/workerType'}, format_checker=None)
ref = 'task.json#/properties/workerType', instance = 'batch'
def _validate_reference(self, ref, instance):
if self._ref_resolver is None:
try:
resolved = self._resolver.lookup(ref)
except referencing.exceptions.Unresolvable as err:
> raise exceptions._WrappedReferencingError(err) from err
E jsonschema.exceptions._WrappedReferencingError: Unresolvable: task.json#/properties/workerType
/bugbug/.venv/lib/python3.12/site-packages/jsonschema/validators.py:464: _WrappedReferencingError
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.