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

Missing conjure-imports can cause misleading errors #751

Open
tjwilson90 opened this issue Nov 11, 2020 · 0 comments
Open

Missing conjure-imports can cause misleading errors #751

tjwilson90 opened this issue Nov 11, 2020 · 0 comments

Comments

@tjwilson90
Copy link

With the following input

# foo.yml
types:
  conjure-imports:
    bar: bar.yml

  definitions:
    default-package: test
    objects:
      Foo:
        fields:
          bar: bar.Bar

# bar.yml
types:
  definitions:
    default-package: test
    objects:
      Bar:
        fields:
          baz: baz.Baz

# baz.yml
types:
  definitions:
    default-package: test
    objects:
      Baz:
        alias: string

I get the error

java.lang.RuntimeException: Encountered error trying to parse file '/Volumes/git/code/gaia/cosmos/cosmos-api/build/conjure/foo.yml'
        at com.palantir.conjure.defs.ConjureParserUtils.lambda$parseConjureDef$3(ConjureParserUtils.java:228)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
        at com.palantir.conjure.defs.ConjureParserUtils.parseConjureDef(ConjureParserUtils.java:199)
        at com.palantir.conjure.defs.Conjure.parse(Conjure.java:37)
        at com.palantir.conjure.cli.ConjureCli$CompileCommand.generate(ConjureCli.java:91)
        at com.palantir.conjure.cli.ConjureCli$CompileCommand.run(ConjureCli.java:85)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1919)
        at picocli.CommandLine.access$1100(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
        at picocli.CommandLine.execute(CommandLine.java:2058)
        at com.palantir.conjure.cli.ConjureCli.main(ConjureCli.java:46)
  Caused by: java.lang.NullPointerException: Import not found for namespace: Namespace{name=baz}
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:987)
        at com.palantir.conjure.defs.ConjureTypeParserVisitor$ByParsedRepresentationTypeNameResolver.resolve(ConjureTypeParserVisitor.java:66)
        at com.palantir.conjure.defs.ConjureTypeParserVisitor.visitForeignReference(ConjureTypeParserVisitor.java:143)
        at com.palantir.conjure.defs.ConjureTypeParserVisitor.visitForeignReference(ConjureTypeParserVisitor.java:41)
        at com.palantir.conjure.parser.types.reference.ForeignReferenceType.visit(ForeignReferenceType.java:33)
        at com.palantir.conjure.defs.ConjureParserUtils.lambda$parseField$10(ConjureParserUtils.java:334)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.Collections$2.tryAdvance(Collections.java:4745)
        at java.base/java.util.Collections$2.forEachRemaining(Collections.java:4753)
        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.defs.ConjureParserUtils.parseField(ConjureParserUtils.java:341)
        at com.palantir.conjure.defs.ConjureParserUtils.parseObjectType(ConjureParserUtils.java:162)
        at com.palantir.conjure.defs.TypeDefinitionParserVisitor.visit(TypeDefinitionParserVisitor.java:56)
        at com.palantir.conjure.defs.TypeDefinitionParserVisitor.visit(TypeDefinitionParserVisitor.java:28)
        at com.palantir.conjure.parser.types.complex.ObjectTypeDefinition.visit(ObjectTypeDefinition.java:42)
        at com.palantir.conjure.defs.ConjureParserUtils.lambda$parseObjects$6(ConjureParserUtils.java:293)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.Collections$2.tryAdvance(Collections.java:4745)
        at java.base/java.util.Collections$2.forEachRemaining(Collections.java:4753)
        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.defs.ConjureParserUtils.parseObjects(ConjureParserUtils.java:294)
        at com.palantir.conjure.defs.ConjureParserUtils.lambda$parseImportObjects$4(ConjureParserUtils.java:253)
        at java.base/java.util.Collections$SingletonSet.forEach(Collections.java:4795)
        at com.palantir.conjure.defs.ConjureParserUtils.parseImportObjects(ConjureParserUtils.java:248)
        at com.palantir.conjure.defs.ConjureParserUtils.lambda$parseConjureDef$3(ConjureParserUtils.java:209)
        ... 13 more

which suggests that my error is in foo.yml when the actual error is in bar.yml.

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