oxidecomputer / oxidecomputer/typify

panic on `$ref` to any path that is not `"#/$defs/xyz`

Open
#828 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

typify2
Dominant language
Rust
Stars
898
Forks
114
Avg merge
4h 18m
Merged PRs (30d)
14

Description

I ran into a panic when running cargo typify ldtk-1-5-3.json (cargo-typify v0.1.0),

It's the same not found ref #/SomeObject is missing from #299, but this time without recursion needed, just a maybe unexpected indirection.

The application panicked (crashed).
Message:  $ref #/LdtkJsonRoot is missing
Location: typify-impl/src/convert.rs:1183
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ (BACKTRACE...) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The Ldtk JSON Schema v1.5.3 uses a reference to its root object.
I'm not sure if this is legal, but LDTK already generates code using QuickType, so I guess they at least allow it.

Here's an overview of the schema,

  {
  	"$schema": "https://json-schema.org/draft-07/schema#",
  	"description": "This file is a JSON schema of files created by LDtk level editor (https://ldtk.io).",
  	"title": "LDtk 1.5.3 JSON schema",
  	"version": "1.5.3",
  	"$ref": "#/LdtkJsonRoot",  // <----  (Is this legal?)

  	"LdtkJsonRoot": {/* ... */},  // <--/--

  	"otherTypes": {/* ... */}
  }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducer command cargo typify ldtk-1-5-3.json and inspect typify-impl/src/convert.rs:1183, where the missing $ref panic is reported. Compare the root $ref and LdtkJsonRoot in the LDtk 1.5.3 schema; done means this schema no longer panics and the command completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.