asdf-format/asdf

Tree containing `id` causes reference resolution failure.

Closed this issue · 1 comments

Description of the problem

The existence of a dictionary with a key id anywhere "higher" in the tree than a reference causes the reference to fail to resolve.

Example of the problem

import asdf


other_tree = {
    'thing': 42,
}

tree = {
    'myref': {
        '$ref': 'external.asdf#/thing'
    }
}

asdf.AsdfFile(other_tree).write_to('external.asdf')

uri=asdf.util.filepath_to_url(os.path.abspath('main.asdf'))
af = asdf.AsdfFile(tree, uri=uri)
af.resolve_references()
assert af['myref'] == 42

tree['id'] = 'bogus'
af = asdf.AsdfFile(tree, uri=uri)
af.resolve_references()  # raises ValueError

System information

asdf version: main
python version: 3.10
operating system: mac osx

Issues like this are probably one of the reasons the more recent JSON-schema drafts have moved to using $id instead of id, see https://json-schema.org/draft-06/draft-wright-json-schema-01#rfc.section.9.2

This might indicate that ASDF should move towards moving its schema specification draft forward to a later draft.