-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Internal error: Defined value expected, but got undefined. #1629
Comments
I don't think this is related to
As someone pointed out in #1062, this error message isn't really helpful.
schema.json{ "$ref": "#/definitions/Pokedex", "definitions": { "Pokedex": { "type": "object", "additionalProperties": false, "description": "A collection of pokémon", "properties": { "pokemon": { "type": "array", "description": "All pokémon contained in the pokédex", "items": { "$ref": "#/definitions/Pokemon" } } }, "required": [ "pokemon" ], "title": "Pokedex" }, "Pokemon": { "type": "object", "additionalProperties": false, "description": "A 'pocket monster.' One must catch them all.", "properties": { "id": { "description": "A unique identifier for this pokémon.\nHigher ids generally imply rarer and more evolved pokémon.", "type": "integer" }, "num": { "type": "string" }, "name": { "type": "string" }, "img": { "description": "Photographic evidence of this pokémon's existence", "type": "string" }, "type": { "type": "array", "items": { "$ref": "#/definitions/Type" } }, "height": { "type": "string" }, "weight": { "type": "string" }, "candy": { "description": "The flavor of candy preferred by this pokémon", "type": "string" }, "candy_count": { "type": "integer" }, "egg": { "type": "string", "enum": [ "2 km", "Not in Eggs", "5 km", "10 km", "Omanyte Candy" ], "title": "egg" }, "spawn_chance": { "type": "number" }, "avg_spawns": { "type": "number" }, "spawn_time": { "type": "string" }, "multipliers": { "oneOf": [ { "type": "array", "items": { "type": "number" } }, { "type": "null" } ], "title": "multipliers" }, "weaknesses": { "type": "array", "description": "Types of pokémon that cause extra damage to this pokémon", "items": { "$ref": "#/definitions/Type" } }, "next_evolution": { "type": "array", "items": { "$ref": "#/definitions/Evolution" } }, "prev_evolution": { "type": "array", "items": { "$ref": "#/definitions/Evolution" } } }, "required": [ "avg_spawns", "candy", "egg", "height", "id", "img", "multipliers", "name", "num", "spawn_chance", "spawn_time", "type", "weaknesses", "weight" ], "title": "pokemon" }, "Type": { "type": "string", "enum": [ "Fire", "Ice", "Flying", "Psychic", "Water", "Ground", "Rock", "Electric", "Grass", "Fighting", "Poison", "Bug", "Fairy", "Ghost", "Dark", "Steel", "Dragon" ], "title": "type" }, "Evolution": { "type": "object", "additionalProperties": false, "description": "A description of an evolutionary stage of a pokémon", "properties": { "num": { "description": "The number of the pokémon to or from which the containing pokémon evolves", "type": "string" }, "name": { "description": "The name of the Pokémon to or from which the containing Pokémon evolves", "type": "string" } }, "required": [ "name", "num" ], "title": "_evolution" } } } This schema passes validation on jsonschemavalidator.net - and yes, the same input on quicktype.io produces code successfully, so I am at a loss here - without an error message explaining what |
So here's why we're not getting a helpful error message: (#1062) Even if I change this into Replacing the body of that error-handling callback with
@noppej could you try the same hack to see if your stack-trace is coming from the same location? (just edit the corresponding (as for fixing #1062, I would suggest catching only a specific, internal class |
For the record, I've tested at least two dozen older versions - it doesn't look like this ever worked. I went back to releases as old as 5 years. How is it the website has a working version, and no version in the npm registry ever worked? Could this be a problem with the CLI front-end itself? (Is the website using the latest version?) |
The problem is here, I think: However, the call to that function is coming from a line that is itself trying to generate an error-message, here: So this obscured error-message is preventing the actual error-message from being generated. It looks like the intention is for
So now we can at least see the intended error-message:
I'm unable to go further with this at the moment, but hopefully this is helpful to the maintainers... |
As to why this works on the website, the constructor looks like a good lead: My guess is, the website never leaves the |
...problem solved. 😅 There was nothing specifically wrong with my schema - even the simple "coordinate" sample from the site wouldn't work. Why? This 👎
Versus this 👍
Apparently the CLI argument parser takes So it looks like I just spent an entire day debugging this because of missing input validation and/or misleading error-reporting. Welp. Looks like it's back to #1062 for this one. |
FWYW -- Looking for clues on resolving the same error message (as said above, this message is unhelpful), I landed on this page. In my case, the issue was the input file name was incorrect. But, as noted above, the actual error message is hidden leaving the users with no guidance. |
I've spent the last couple of days hunting for errors in my schemas and hit the same as @robogeek. It would make sense to validate that the input files exist in the CLI and give a more meaningful message that this obtuse one later on in the process. This is one of several obtuse messages that are hard to track back to the source of the issue - but this seems easy enough to improve on compared to some of the others (e.g. 'Error: Value of type string is not valid JSON Schema' which can have a variety of causes). I think input validation is worth doing as when enabling |
Quicktype fails on almost any non-trivial TypeScript file I throw at it trying to convert to Rust. A trivial file such as the following works: interface RunOptions {
absolutePaths: boolean
ancestry: boolean
iframes: boolean
xpath: boolean
}
...
use serde::{Serialize, Deserialize};
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RunOptions {
absolute_paths: bool,
ancestry: bool,
iframes: bool,
xpath: bool,
} It won't run at all on export { RunOptions } from 'axe-core' from axe.d.ts: declare namespace axe {
...
interface RunOptions {
runOnly?: RunOnly | TagValue[] | string[] | string;
rules?: RuleObject;
reporter?: ReporterVersion | string;
resultTypes?: resultGroups[];
selectors?: boolean;
ancestry?: boolean;
xpath?: boolean;
absolutePaths?: boolean;
iframes?: boolean;
elementRef?: boolean;
frameWaitTime?: number;
preload?: boolean;
performanceTimer?: boolean;
pingWaitTime?: number;
}
... I get this horribly frustrating error that seems to have been in quicktype for years, with no way to diagnose what is going on, and no way to fix it:
And now the web site no longer even supports TypeScript input, so it seems someone isn't telling us something. 🤔 |
The quicktype CLI fails with the above error, when executing the following
quicktype --lang rs --derive-debug --density dense --visibility private --out debugProtocolTypes.rs --src-lang typescript --src-urls https://raw.githubusercontent.com/microsoft/vscode/master/src/vs/workbench/contrib/debug/common/debugProtocol.d.ts
The same input file and options on quicktype.io produces code successfully.
The text was updated successfully, but these errors were encountered: