palantir / palantir/conjure-java

Bad error message on empty union

Open
#684 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
39
Forks
49
Avg merge
8h 22m
Merged PRs (30d)
32

Description

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.

Contributor guide

Open the contributing guide

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

Reproduce the empty-union YAML with the ConjureJavaCli entry point, then inspect ObjectGenerator.generateTypes and TypeGenerator around the JavaPoet stack trace. Done means the input either generates successfully or is rejected with a clear error instead of the unindent exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.