Skip to content
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

Bad error message on empty union #684

Open
raiju opened this issue Dec 17, 2019 · 0 comments
Open

Bad error message on empty union #684

raiju opened this issue Dec 17, 2019 · 0 comments

Comments

@raiju
Copy link
Contributor

raiju commented Dec 17, 2019

What happened?

When given the following conjure:

types:
  definitions:
    default-package: com.palantir.foo.api
    objects:
      Bar:
        union: {}

the following error is emitted:

Exception in thread "main" picocli.CommandLine$ExecutionException: Error while running command (com.palantir.conjure.java.cli.ConjureJavaCli$GenerateCommand@3315d2d7): java.lang.IllegalArgumentException: cannot unindent 1 from 0
        at picocli.CommandLine.execute(CommandLine.java:1051)
        at picocli.CommandLine.access$900(CommandLine.java:142)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:1246)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:1214)
        at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:1122)
        at picocli.CommandLine.parseWithHandlers(CommandLine.java:1405)
        at picocli.CommandLine.run(CommandLine.java:1864)
        at picocli.CommandLine.run(CommandLine.java:1794)
        at com.palantir.conjure.java.cli.ConjureJavaCli.main(ConjureJavaCli.java:45)
Caused by: java.lang.IllegalArgumentException: cannot unindent 1 from 0
        at com.squareup.javapoet.Util.checkArgument(Util.java:53)
        at com.squareup.javapoet.CodeWriter.unindent(CodeWriter.java:107)
        at com.squareup.javapoet.CodeWriter.unindent(CodeWriter.java:103)
        at com.squareup.javapoet.TypeSpec.emit(TypeSpec.java:317)
        at com.squareup.javapoet.JavaFile.emit(JavaFile.java:156)
        at com.squareup.javapoet.JavaFile.writeTo(JavaFile.java:76)
        at com.squareup.javapoet.JavaFile.toString(JavaFile.java:175)
        at com.squareup.javapoet.JavaFile.hashCode(JavaFile.java:169)
        at java.base/java.util.HashMap.hash(HashMap.java:339)
        at java.base/java.util.HashMap.put(HashMap.java:607)
        at java.base/java.util.HashSet.add(HashSet.java:220)
        at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
        at com.palantir.conjure.java.types.ObjectGenerator.generateTypes(ObjectGenerator.java:56)
        at com.palantir.conjure.java.types.TypeGenerator.generate(TypeGenerator.java:37)
        at com.palantir.conjure.java.types.TypeGenerator.emit(TypeGenerator.java:51)
        at com.palantir.conjure.java.cli.ConjureJavaCli$GenerateCommand.run(ConjureJavaCli.java:163)
        at picocli.CommandLine.execute(CommandLine.java:1043)
        ... 8 more

This happened while developing a new API spec (the union was left empty while working on a different part of the API).

What did you want to happen?

Either the input is accepted & code generates, or the input is rejected with a better error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant