[BUG]: "Option parsing failed: ." when providing input/src file as positional argument
Braincompiler opened this issue ยท 12 comments
Running quicktype with:
npx quicktype src/systemregler.schema.json --src-lang schema --top-level Configuration --lang python --out src/parameters/types.py
or
npx quicktype --src-lang schema --top-level Configuration --lang python --out src/parameters/types.py src/systemregler.schema.json
... fails with the meaningless error: Option parsing failed: . After some digging in I found out the problem seems to be the messageError function at https://github.com/glideapps/quicktype/blob/master/src/index.ts#L731 or the exceptionToString function from the ts-necessities package. The exception message was actually "Unknown value: src/systemregler.schema.json" which is the name of the input file as a positional argument. Which in turn seems to be another bug, since according to the README, positional arguments for the input are allowed: https://github.com/glideapps/quicktype?tab=readme-ov-file#using-quicktype. If not, the documentation needs to be updated.
It was working before, so maybe the bug is a regression with the latest update.
Issue Type
input parsing
Context (Environment, Version, Language)
Input Format: JSONSchema
Output Language: Python
CLI, npm, or app.quicktype.io: npm
Version: 23.2.5
Description
Running quicktype with:
npx quicktype --src-lang schema --top-level Configuration --lang python --out src/parameters/types.py --src src/systemregler.schema.json
... workarounds the problem and quicktype is working as expected.
Expected Behaviour / Output
Positional arguments should work again or the error needs to be more meaningful.
Current Behaviour / Output
Meaningless error: Option parsing failed: .
Steps to Reproduce
- Run quicktype with positional argument instead of
--srcoption.
It's not limited to positional arguments either it seems, I'm seeing this error whenever using --just-types.
23.2.4 is unaffected, but those versions don't appear to be tagged here nor is there a changelog making hard to identify why I should upgrade or which version to pin to.
We were hit by this one too, and to contrast with OP's message, suppressing positional args doesn't help.
The command
npx quicktype --src-lang schema --lang ts --top-level MyTypeName --prefer-unions --no-runtime-typecheck --no-runtime-typecheck-ignore-unknown-properties --src ./MySchema.schema.json --out ./mytype.generated.types.ts
stills ends up with Error: Option parsing failed: .
I tried to wrap all arguments values with quote, but still the same message.
The same command as above, but with npx quicktype@23.2.4 ... works (as before).
Same issue here running:
npx quicktype -s schema my.schema.json -o output.cs
quicktype --src-lang schema --src board.json --lang java -o Board.java --package com.example.demo.models.board --array-type list --lombok --lombok-copy-annotations
Error: Option parsing failed: .
regression introduced on 23.2.5:
https://socket.dev/npm/package/quicktype/diff/23.2.5
https://socket.dev/npm/package/quicktype-core/diff/23.2.5
probably introduced by this specific commit: b747e4b
@Braincompiler
After some digging in I found out the problem seems to be themessageErrorfunction at https://github.com/glideapps/quicktype/blob/master/src/index.ts#L731 or theexceptionToStringfunction from thets-necessitiespackage.
at the first look, I also think that the error was on the line 731, but after some debugging it seems to break at the line 738:
Lines 736 to 742 in b747e4b
for me, it failed on check that no-runtime-typecheck is null
quicktype relies on https://www.npmjs.com/package/command-line-args for args parsing
see: https://github.com/75lb/command-line-args/wiki/Notation-rules
on the provided commit that introduces the regression, the main change is from type: String to optionType: "string", but I haven't found any reference for optionType in the command-line-args
moreover, the official lib docs uses type: Boolean for negating flags: https://github.com/75lb/command-line-args/wiki/How-to-implement-a-negating-flag
@inferrinizzard there is no reference for optionType in the source code of command-line-args (see https://grep.app/search?f.repo.pattern=75lb%2Fcommand-line-args&q=optionType).
if it was a change only for the quicktype, it's missing an adapter to convert from optionType to the type.
Just noticed this when trying the examples on the website and the URL ones didn't work.
But even when this is fixed, this one will still fail since the link is dead:
Technically, a different issue, but while you're at it...
(https://megalinter.io has https://lychee.cli.rs for checking dead links.)
Hey folks, working on a fix currently
but in the meantime, please use 23.2.4 as a workaround ๐
This should be fixed as of 23.2.6
Just tested. We can confirm that the problem is fixed for us.
Many thanks & kudos!
Confirmed, Bug is fixed! Thanks!



