google / google/closure-templates

SoyFileSet.extractMsgs - error in one template truncates message bundle

Open
#104 1 comment 0 reactions 1 assignee Claimed by @mikesamuel View on GitHub
Dominant language
Java
Stars
700
Forks
199
Avg merge
2d 12h
Merged PRs (30d)
26

Description

Reproduction: Create a SoyFileSet containing two files: a valid file with a message and one that lacks a namespace declaration

Example file content:

foo.soy

``` soy
{namespace foo}

/** */
{template .test}
{msg desc=""}Test msg{/msg}
{/template}
```

invalid.soy

``` soy
/** */
{template .test}
invalid due to missing namespace
{/template}
```

If the valid file is added first, extractMsgs() will return its message. If the invalid soy is added first, then the bundle will not contain the message. In that case, SoyFileSet.generateTemplateRegistry also excludes the second file's template, and SoyFileSet.compileToTofu throws an exception (as expected).

I presume that extractMsgs does not compile the templates / throw an exception so that the process that extracts messages does not need to have the same configuration (globals, file set, etc) as the real application. But I would expect that an unrecoverable error in one file would not silently truncate the resulting bundle.

We caught this only because we have an alert when the number of translations drops by 10% or more, but I'm not sure how to prevent it from happening in the future other than developer education.

Thoughts?

Thank you,
Rob

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.