canonical / canonical/cloud-init

Deal with jsonschema's automatic remote reference resolving deprecation

Open
#5,855 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report

`jsonschema` will drop support for automatically retrieving [remote references](https://github.com/canonical/cloud-init/blob/aeccf89914031422604e41080c50cba8a0717743/cloudinit/config/schemas/versions.schema.cloud-config.json#L17) in the future.

```
tests/unittests/config/test_schema.py::TestVersionedSchemas::test_versioned_cloud_config_schema_is_valid_json[schema4-None]
/home/aciba/canonical/server/cloud-init/5175-depre-warnings/cloudinit/config/schema.py:462: DeprecationWarning: Automatically retrieving remote references can be a security vulnerability and is discouraged by the JSON Schema specifications. Relying on this behavior is deprecated and will shortly become an error. If you are sure you want to remotely retrieve your reference and that it is safe to do so, you can find instructions for doing so via referencing.Registry in the referencing documentation (https://referencing.readthedocs.org).
all_errs = list(
```

## Possible solutions

1. Directly manipulate `python3-referencing` to resolve references before passing the schema to `jsonchema`.
2. Remove remote references. As the only [remote reference](https://github.com/canonical/cloud-init/blob/aeccf89914031422604e41080c50cba8a0717743/cloudinit/config/schemas/versions.schema.cloud-config.json#L17) is contained in this project, we could directly put `schema-cloud-config-v1.json` into `versions.schema.cloud-config.json` removing the indirection and the problem.

## Steps to reproduce the problem

Run `pytest tests/unittest` on Python 3.12+.

## Environment details
- Cloud-init version: main
- Operating System Distribution: N/A
- Cloud provider, platform or installer type: N/A

## cloud-init logs

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.