pksunkara / alpaca

Given a web API, Generate client libraries in node, php, python, ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Run-time error when running Alpaca on files

samford opened this issue · comments

I started working on some libraries for the NewsBlur API and decided to use Alpaca for this but for some reason I get a run-time error when I run it on my files (you can find the repo here). I looked through the example code in the README and set up my files similar to the examples in the examples folder.

When I run Alpaca on the Buffer and Helpful examples the various libraries are created fine so it's probably safe to assume that the issue is specifically related to my files. I've tried debugging it for a while but I can't see anything that would be causing the issue (but I may be blinded from having looked at this for so long).

For what it's worth, I'm using Go 1.2 (installed using GVM) on Mac OS X 10.10.3 and I installed Alpaca using the "by using golang (v1.2)" instructions in the README; I've also tried the provided i386 Darwin binary but it produces the same run-time error.

That having been said, here's the error I receive when running alpaca . in the directory:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0xf8 pc=0x62c1d]

goroutine 1 [running]:
runtime.panic(0x30e340, 0x718919)
    /Users/sam/.gvm/gos/go1.2/src/pkg/runtime/panic.c:266 +0xb6
text/template.errRecover(0x890d48)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:100 +0xb9
runtime.panic(0x30e340, 0x718919)
    /Users/sam/.gvm/gos/go1.2/src/pkg/runtime/panic.c:248 +0x106
github.com/pksunkara/alpaca/alpaca.func·005(0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/sam/.gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/utils.go:92 +0xfd
github.com/pksunkara/alpaca/alpaca.func·006(0x271cc0, 0xc21028e1e0, 0xc21043aab0, 0xc21041e607, 0x2, ...)
    /Users/sam/.gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/utils.go:153 +0x3fc
reflect.Value.call(0x2fc060, 0xc210464190, 0x130, 0x372f20, 0x4, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/reflect/value.go:474 +0xe0b
reflect.Value.Call(0x2fc060, 0xc210464190, 0x130, 0xc21024a000, 0x4, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/reflect/value.go:345 +0x9d
text/template.call(0x2fc060, 0xc210464190, 0xc21042b200, 0x4, 0x4, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/funcs.go:210 +0x8d0
reflect.Value.call(0x2ed100, 0x4230a8, 0x130, 0x372f20, 0x4, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/reflect/value.go:474 +0xe0b
reflect.Value.Call(0x2ed100, 0x4230a8, 0x130, 0xc210468f00, 0x5, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/reflect/value.go:345 +0x9d
text/template.(*state).evalCall(0xc2104660c0, 0x32e900, 0xc210412968, 0x196, 0x2ed100, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:555 +0x87f
text/template.(*state).evalFunction(0xc2104660c0, 0x32e900, 0xc210412968, 0x196, 0xc210470520, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:447 +0x297
text/template.(*state).evalCommand(0xc2104660c0, 0x32e900, 0xc210412968, 0x196, 0xc21046a330, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:351 +0x1ab
text/template.(*state).evalPipeline(0xc2104660c0, 0x32e900, 0xc210412968, 0x196, 0xc210460370, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:324 +0x14c
text/template.(*state).walk(0xc2104660c0, 0x32e900, 0xc210412968, 0x196, 0x85e588, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:159 +0x104
text/template.(*state).walk(0xc2104660c0, 0x32e900, 0xc210412968, 0x196, 0x85e4f8, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:167 +0x729
text/template.func·001(0x284380, 0x5, 0x20, 0x32e900, 0xc210412968, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:249 +0x16d
text/template.(*state).walkRange(0xc2104660c0, 0x321bc0, 0xc210265e00, 0x196, 0xc2104672a0)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:258 +0x3a1
text/template.(*state).walk(0xc2104660c0, 0x321bc0, 0xc210265e00, 0x196, 0x85e8e8, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:170 +0x243
text/template.(*state).walk(0xc2104660c0, 0x321bc0, 0xc210265e00, 0x196, 0x85e4f8, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:167 +0x729
text/template.(*state).walkIfOrWith(0xc2104660c0, 0x13, 0x321bc0, 0xc210265e00, 0x196, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:195 +0x22a
text/template.(*state).walk(0xc2104660c0, 0x321bc0, 0xc210265e00, 0x196, 0x85e8a0, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:178 +0x5d5
text/template.(*state).walk(0xc2104660c0, 0x321bc0, 0xc210265e00, 0x196, 0x85e4f8, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:167 +0x729
text/template.func·001(0x284380, 0x2, 0x20, 0x321bc0, 0xc210265e00, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:249 +0x16d
text/template.(*state).walkRange(0xc2104660c0, 0x269300, 0xc210463540, 0x160, 0xc210467450)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:258 +0x3a1
text/template.(*state).walk(0xc2104660c0, 0x269300, 0xc210463540, 0x160, 0x85e8e8, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:170 +0x243
text/template.(*state).walk(0xc2104660c0, 0x269300, 0xc210463540, 0x160, 0x85e4f8, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:167 +0x729
text/template.(*state).walkIfOrWith(0xc2104660c0, 0x13, 0x269300, 0xc210463540, 0x160, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:195 +0x22a
text/template.(*state).walk(0xc2104660c0, 0x269300, 0xc210463540, 0x160, 0x85e8a0, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:178 +0x5d5
text/template.(*state).walk(0xc2104660c0, 0x269300, 0xc210463540, 0x160, 0x85e4f8, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:167 +0x729
text/template.(*Template).Execute(0xc210466000, 0x850140, 0xc21045ff88, 0x269300, 0xc210463540, ...)
    /Users/sam/.gvm/gos/go1.2/src/pkg/text/template/exec.go:147 +0x2f8
github.com/pksunkara/alpaca/alpaca.WriteTemplate(0xc210466000, 0x38cc90, 0x9, 0x269300, 0xc210463540)
    /Users/sam/.gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/template.go:24 +0xd7
github.com/pksunkara/alpaca/alpaca.func·001(0x39b470, 0x9, 0x38cc90, 0x9, 0x269300, ...)
    /Users/sam/.gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/template.go:30 +0xf5
github.com/pksunkara/alpaca/alpaca.WritePhp(0xc210463540)
    /Users/sam/.gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/langs_php.go:14 +0x13e
github.com/pksunkara/alpaca/alpaca.WriteLibraries(0xc21028e618)
    /Users/sam/.gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/alpaca/alpaca.go:70 +0x88
main.main()
    /Users/sam/.gvm/pkgsets/go1.2/global/src/github.com/pksunkara/alpaca/main.go:52 +0x21a

goroutine 6 [finalizer wait]:
runtime.park(0xc210, 0x71cd78, 0x71ad28)
    /Users/sam/.gvm/gos/go1.2/src/pkg/runtime/proc.c:1342 +0x66
runfinq()
    /Users/sam/.gvm/gos/go1.2/src/pkg/runtime/mgc0.c:2276 +0x84
runtime.goexit()
    /Users/sam/.gvm/gos/go1.2/src/pkg/runtime/proc.c:1394

Let me know if you have any ideas in terms of troubleshooting the issue or if I've overlooked something in my formatting of the JSON files. Thanks!

Hey @samford.

Please compile the master branch using go version 1.4. Don't use the binaries provided since the files you are using are of new format. So, stick with the master branch.

The 2 main problem you are having are:

  • Whenever there is a parameter in the API, it needs a desc in doc.json even if it is for url_use. (readers -> feed in doc.json is missing id param)
  • Whenever a parameter is required in the API, it needs a value in the doc.json after desc key.

There are 2 suggestions I am giving you based on your files:

  • Don't use import as a class or function name since it is a keyword in python
  • Alpaca doesn't handle files arguments, so please check that opml_upload is okay.

I was originally using Go 1.4 but I switched to 1.2 after running into trouble (just in case that was contributing to the issue). I switched back to using Go 1.4 and recompiled Alpaca, so I'm good there.

You have an excellent eye; those problems were exactly what was wrong. After I fixed those two issues Alpaca happily processed the files.

I appreciate your suggestions and I'll keep them in mind as I move forward with this. Thanks very much for your helpful response (and Alpaca).