dpinol / closure-templates

Automatically exported from code.google.com/p/closure-templates
Apache License 2.0
0 stars 0 forks source link

Crash if msg placeholder does not match. #61

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
We discovered this when one of our translators misunderstood and translated a 
placeholder.

What steps will reproduce the problem?

1. Use a Soy template with a placeholder, such as:

 {namespace Test}
 /**
  * @param number
  */
 {template .test}
   {msg desc=""}{$number} things{/msg}
 {/template}

2. Create a translation file that changes the id property of the placeholder:

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file original="SoyMsgBundle" datatype="x-soy-msg-bundle" xml:space="preserve" source-language="en" target-language="fr">
    <body>
      <trans-unit id="394055013080502380" datatype="html">
        <source><x id="NUMBER"/> things</source>
        <target><x id="NOMBRE"/> choses</target>
      </trans-unit>
    </body>
  </file>
</xliff>

3. Compile the template

$ java -jar SoyToJsSrcCompiler.jar --locales fr --messageFilePathFormat a.xml 
--outputPathFormat t.js t.soy

What is the expected output? What do you see instead?

We would expect to see a useful error explaining (e.g., "no placeholder found 
that matches id="NOMBRE"") so that the bad translation can be quickly found and 
fixed.

Instead, we see a stack dump:
    at com.google.template.soy.msgs.internal.InsertMsgsVisitor.visitMsgNode(InsertMsgsVisitor.java:143)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:69)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:54)
    at com.google.template.soy.basetree.AbstractNodeVisitor.visitChildrenAllowingConcurrentModification(AbstractNodeVisitor.java:74)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitChildrenAllowingConcurrentModification(AbstractSoyNodeVisitor.java:135)
    at com.google.template.soy.msgs.internal.InsertMsgsVisitor.visitSoyNode(InsertMsgsVisitor.java:207)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitTemplateNode(AbstractSoyNodeVisitor.java:160)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitTemplateBasicNode(AbstractSoyNodeVisitor.java:152)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:64)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:54)
    at com.google.template.soy.basetree.AbstractNodeVisitor.visitChildrenAllowingConcurrentModification(AbstractNodeVisitor.java:74)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitChildrenAllowingConcurrentModification(AbstractSoyNodeVisitor.java:135)
    at com.google.template.soy.msgs.internal.InsertMsgsVisitor.visitSoyNode(InsertMsgsVisitor.java:207)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitSoyFileNode(AbstractSoyNodeVisitor.java:148)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:62)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:54)
    at com.google.template.soy.basetree.AbstractNodeVisitor.visitChildrenAllowingConcurrentModification(AbstractNodeVisitor.java:74)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitChildrenAllowingConcurrentModification(AbstractSoyNodeVisitor.java:135)
    at com.google.template.soy.msgs.internal.InsertMsgsVisitor.visitSoyNode(InsertMsgsVisitor.java:207)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visitSoyFileSetNode(AbstractSoyNodeVisitor.java:144)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:61)
    at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:54)
    at com.google.template.soy.basetree.AbstractNodeVisitor.exec(AbstractNodeVisitor.java:39)
    at com.google.template.soy.msgs.internal.InsertMsgsVisitor.exec(InsertMsgsVisitor.java:103)
    at com.google.template.soy.jssrc.internal.JsSrcMain.genJsSrc(JsSrcMain.java:155)
    at com.google.template.soy.jssrc.internal.JsSrcMain.genJsFiles(JsSrcMain.java:194)
    at com.google.template.soy.SoyFileSet.compileToJsSrcFiles(SoyFileSet.java:760)
    at com.google.template.soy.SoyToJsSrcCompiler.execMain(SoyToJsSrcCompiler.java:259)
    at com.google.template.soy.SoyToJsSrcCompiler.main(SoyToJsSrcCompiler.java:205)

What version of the product are you using? On what operating system?

The most recent snapshot, dated Dec 22, 2011.

Original issue reported on code.google.com by kient...@catch.com on 26 Jun 2012 at 7:41

GoogleCodeExporter commented 8 years ago
Closure Templates has migrated to GitHub: 
https://github.com/google/closure-templates. Please reopen this there if it's 
still an issue.

Original comment by brendan....@gmail.com on 27 Feb 2015 at 12:10