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

Multi-lingual site translation panic error #2174

Closed
rogeruiz opened this issue May 28, 2016 · 8 comments
Closed

Multi-lingual site translation panic error #2174

rogeruiz opened this issue May 28, 2016 · 8 comments
Labels

Comments

@rogeruiz
Copy link

rogeruiz commented May 28, 2016

Description

I'm currently working on a project which uses Hugo to build a multi-lingual site. When running the following command:

hugo --baseURL="https://vote-gov-staging.apps.cloud.gov"

with the following config* files:

  • config.toml
  • config_en.toml
  • config_es.toml

and no lang property in the config.toml is causing the following issue / panic:

Error

~/Developer/18f/vote-gov staging  33s
❯❯❯❯❯❯❯ hugo --baseURL="https://vote-gov-staging.apps.cloud.gov"
panic: reflect: Zero(nil) [recovered]
    panic: reflect: Zero(nil)

goroutine 1 [running]:
text/template.errRecover(0xc8204172c8)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:104 +0x15b
reflect.Zero(0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/reflect/value.go:2099 +0x85
text/template.(*state).validateType(0xc820417258, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:625 +0x886
text/template.(*state).evalArg(0xc820417258, 0x73ea60, 0xc82053c240, 0x16, 0x0, 0x0, 0x1b6a0a0, 0xc820246190, 0x0, 0x0, ...)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:671 +0x4a6
text/template.(*state).evalChainNode(0xc820417258, 0x73ea60, 0xc82053c240, 0x16, 0xc820238a80, 0xc820015f40, 0x1, 0x1, 0x0, 0x0, ...)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:441 +0x288
text/template.(*state).evalCommand(0xc820417258, 0x73ea60, 0xc82053c240, 0x16, 0xc82023e2a0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:369 +0x31c
text/template.(*state).evalPipeline(0xc820417258, 0x73ea60, 0xc82053c240, 0x16, 0xc820246140, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:345 +0x180
text/template.(*state).walk(0xc820417258, 0x73ea60, 0xc82053c240, 0x16, 0x1b648d8, 0xc82023e3f0)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:180 +0x135
text/template.(*state).walk(0xc820417258, 0x73ea60, 0xc82053c240, 0x16, 0x1b6a678, 0xc82023e0f0)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:188 +0x776
text/template.(*Template).Execute(0xc820238740, 0x1b65910, 0xc8204c81c0, 0x73ea60, 0xc82053c240, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/text/template/exec.go:143 +0x2b6
html/template.(*Template).ExecuteTemplate(0xc8201f4000, 0x1b65910, 0xc8204c81c0, 0x790e50, 0xa, 0x73ea60, 0xc82053c240, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/html/template/template.go:118 +0xb7
github.com/spf13/hugo/hugolib.(*Site).renderThing(0xc8201d2000, 0x73ea60, 0xc82053c240, 0x790e50, 0xa, 0x1b65910, 0xc8204c81c0, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/hugolib/site.go:1521 +0x215
github.com/spf13/hugo/hugolib.(*Site).render(0xc8201d2000, 0x7906c0, 0x8, 0x73ea60, 0xc82053c240, 0xc8204c81c0, 0xc820176ba0, 0x2, 0x2, 0x0, ...)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/hugolib/site.go:1496 +0x2f8
github.com/spf13/hugo/hugolib.(*Site).renderAndWritePage(0xc8201d2000, 0x7906c0, 0x8, 0x774c00, 0x1, 0x73ea60, 0xc82053c240, 0xc820176ba0, 0x2, 0x2, ...)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/hugolib/site.go:1447 +0xde
github.com/spf13/hugo/hugolib.(*Site).RenderHomePage(0xc8201d2000, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/hugolib/site.go:1262 +0x194
github.com/spf13/hugo/hugolib.(*Site).Render(0xc8201d2000, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/hugolib/site.go:403 +0x1a4
github.com/spf13/hugo/hugolib.(*Site).Build(0xc8201d2000, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/hugolib/site.go:246 +0x80
github.com/spf13/hugo/commands.buildSite(0xc820417b57, 0x1, 0x1, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/commands/hugo.go:458 +0xcf
github.com/spf13/hugo/commands.build(0x0, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/commands/hugo.go:348 +0x370
github.com/spf13/hugo/commands.glob.func9(0xb170e0, 0xc82016a820, 0x0, 0x1)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/commands/hugo.go:58 +0x32
github.com/spf13/cobra.(*Command).execute(0xb170e0, 0xc82008c010, 0x1, 0x1, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/cobra/command.go:572 +0x869
github.com/spf13/cobra.(*Command).ExecuteC(0xb170e0, 0xb170e0, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/cobra/command.go:662 +0x54e
github.com/spf13/cobra.(*Command).Execute(0xb170e0, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/cobra/command.go:618 +0x2d
github.com/spf13/hugo/commands.Execute()
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/hugo/commands/hugo.go:72 +0x44
main.main()
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/main.go:24 +0x28

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1

goroutine 21 [chan receive]:
github.com/spf13/viper.(*Viper).WatchConfig.func1(0xc8201261c0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/viper/viper.go:268 +0x1f1
created by github.com/spf13/viper.(*Viper).WatchConfig
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/viper/viper.go:269 +0x35

goroutine 4 [syscall]:
syscall.Syscall6(0x16b, 0x3, 0x0, 0x0, 0xc820192e70, 0xa, 0xb44f90, 0x7, 0x3085, 0x2f0d1)
    /usr/local/Cellar/go/1.5.1/libexec/src/syscall/asm_darwin_amd64.s:41 +0x5
syscall.kevent(0x3, 0x0, 0x0, 0xc820192e70, 0xa, 0xb44f90, 0xb204a0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5.1/libexec/src/syscall/zsyscall_darwin_amd64.go:202 +0x77
syscall.Kevent(0x3, 0x0, 0x0, 0x0, 0xc820192e70, 0xa, 0xa, 0xb44f90, 0x0, 0x0, ...)
    /usr/local/Cellar/go/1.5.1/libexec/src/syscall/syscall_bsd.go:447 +0x94
gopkg.in/fsnotify%2ev1.read(0x3, 0xc820192e70, 0xa, 0xa, 0xb44f90, 0x0, 0x0, 0x0, 0x0, 0x0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/gopkg.in/fsnotify.v1/kqueue.go:471 +0x8d
gopkg.in/fsnotify%2ev1.(*Watcher).readEvents(0xc8201b2240)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/gopkg.in/fsnotify.v1/kqueue.go:278 +0x199
created by gopkg.in/fsnotify%2ev1.NewWatcher
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/gopkg.in/fsnotify.v1/kqueue.go:61 +0x33f

goroutine 5 [select]:
github.com/spf13/viper.(*Viper).WatchConfig.func1.1(0xc8201b2240, 0xc8201261c0)
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/viper/viper.go:243 +0x4ad
created by github.com/spf13/viper.(*Viper).WatchConfig.func1
    /private/tmp/hugo20151125-13930-1yibo46/hugo-0.15/src/github.com/spf13/viper/viper.go:256 +0x197

Adding a lang = "en-US" to the config.toml fixes the issue and causes Hugo to build properly

Fix

diff --git a/config.toml b/config.toml
index 61f08af..18de0ac 100644
--- a/config.toml
+++ b/config.toml
@@ -7,5 +7,6 @@ title = "Voter Registration"
 registration_type = "registration_types"

 [params]
+lang = "en-US"
 Owner = "USA.gov"
 Referrer_Short_Code = "voteusa"

Hypothesis

It seems like the issue is in regards to not having the lang = "en-US" in the default config file. I think I've tracked it down to the translations directory containing two yaml files which reflect the lang = "*" within each configuration file. With the lang = "*" missing and the translations/*.yml files existing, the panic occurs.

I would love to help with debugging this issue further and even contributing some documentation around troubleshooting this error in the docs. Let me know how I can help. Thanks!

@bep
Copy link
Member

bep commented May 28, 2016

Please use http://discuss.gohugo.io/ for troubleshooting/questions.

@bep bep closed this as completed May 28, 2016
@rogeruiz
Copy link
Author

@bep I'm pretty certain that the Hugo binary throwing a panic in the viper library goes beyond troubleshooting. I've fixed the issue in my project using Hugo but I figured opening an issue here would be helpful to the Hugo community and make the issue visible because this seems like an issue introduced when Multi-lingual support was added to Hugo. A go panic because a property is missing from the config file doesn't really help anyone trying to learn how to use Hugo. I know that discussions on troubleshooting the library or helping others in the community should be opened in the Discourse app, but this error message can be tied to the source code. I could go ahead and open another issue in @spf13's viper, it seemed like this was in error in Hugo since it was about language support and not about reading the config.

Let me know if I can help out with this in anyway, rather than keeping this bug in the source or working around the bug like I did above.

@anthonyfok anthonyfok reopened this May 29, 2016
@bep
Copy link
Member

bep commented May 29, 2016

There isn't a "multi-lingual" feature in Hugo. The stack trace indicates a nil pointer inside a template, which could be anything, panics are hard to avoid totally (we could recover, but we'll not doing that). Oh, and lots of stuff have happened in Hugo since 0.15.

If you have further questions, please take it on the forum. Until I'm convinced that this issue is something that is "actionable", I'm closing this. We have a limited set of support resources, so this is keeping it as effective as possible.

@bep bep closed this as completed May 29, 2016
@anthonyfok
Copy link
Member

Hi @rogeruiz,

because this seems like an issue introduced when Multi-lingual support was added to Hugo

Could you please tell us which version of Hugo you used when this happened? Was it:

  1. HEAD of master branch?
  2. v0.15?
  3. master patched with Pull Request Native Multilingual support in Hugo. #1734: "Native Multilingual support in Hugo"?

because AFAIK Hugo does not yet have native multilingual supported added to it yet, except a temporary but good solution contributed by a Hugo user in examples/multilingual.

It would also be helpful if you could provide the source to an example minimal website so we could try to reproduce the error that you encountered.

Many thanks!

@rogeruiz
Copy link
Author

rogeruiz commented May 31, 2016

Hey @anthonyfok,

We're using the v0.15 release and leveraging the work in examples/mulilingual to build multilingual sites. usagov/vote-gov#69 contains an outline of what reproduces fixes the error, if you'd like to check that out. Otherwise, I'll create a minimal example website to help reproduce the error locally.

Thanks.

@anthonyfok
Copy link
Member

@rogeruiz: Thank you for your added information. I would recommend that you try to build Hugo from source (or wait for the 0.16, which is happening within this week or even sooner) and see if it solves your problem. Lots of fixes have gone into the eight months of development between the two releases, so it is likely that the problem has been solved.

As both @ bep and I pointed out, Hugo does not yet have any native multilingual support, not even for 0.16, so the problem you ran into seems more like using a variable without declaring it first, and that variable happens to be lang; the same would have occurred if you had renamed the variable to lingua or apple or what not.

Cheers,
Anthony

@yozlet
Copy link

yozlet commented Sep 15, 2016

Further to what @rogeruiz was saying, and on the same project: Bug still appears present in 0.16. I believe it happens when using index to look up a TOML key that doesn't exist. I'll try and get more info after we've launched the new version of vote.gov.

@github-actions
Copy link

github-actions bot commented Apr 3, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants