Bugreport 0.5.7 with dash and underscore in json encoding decoding roundtrip

25 views
Skip to first unread message

bart van deenen

unread,
Mar 22, 2013, 5:17:39 AM3/22/13
to pi...@googlegroups.com
Hi Anton

unfortunately I'm still on 0.5.7, I'll move to the latest as soon as the current project I'm working on is stabilized.

I've found a bug in json encoding with an enumeration with a dash in one of the options. I've narrowed it down to very simple testcase:

I've added the issue to github:

$ cat test.piqi:
.enum [ .name dash                                                                                                  
    .option [ .name with-dash ]                                                                                     
]                                                                                                                   
                                                                                                                    
.record [ .name test                                                                                                
    .field [ .type dash ]                                                                                           
]                                                                                                                   

$ erl

1> piqi:start().
ok
2> c(test_piqi), c(test_piqi_ext), rr("*").
[test_test]
3> rl(test_test).
-record(test_test,{dash}).
ok
4> R=#test_test{ dash= with_dash }.
#test_test{dash = with_dash}
5> Json = test_piqi_ext:gen_test(R, json).
<<"{\"dash\":\"with_dash\"}">>
6> test_piqi_ext:parse_test(Json, json).
** exception throw: {piqirun_ext_error,"input:1:9: unknown enum option: \"with_dash\""}
     in function  piqirun_ext:convert/6 (src/piqirun_ext.erl, line 72)
     in call from test_piqi_ext:parse_test/2 (test_piqi_ext.erl, line 15)
7> Xml = test_piqi_ext:gen_test(R, xml). 
<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test><dash>with-dash</dash></test>\n">>
8> test_piqi_ext:parse_test(Xml,xml).
#test_test{dash = with_dash}


I can't yet move to 0.6 but it'll definitely happen within 2 months, because we need to move forward, and we're going to build a lot on the internal piqi xml representation.

Any hints on where to look in the code, maybe we can fix it ourselves?

Thanks

Bart

Anton Lavrik

unread,
Mar 22, 2013, 11:37:26 AM3/22/13
to pi...@googlegroups.com
Hi Bart, this is a one-line fix for this bug:
https://github.com/alavrik/piqi/commit/322fc99bb05e2ffdc111969b28ccedf47d1c1cb4

Anton

bart van deenen

unread,
Mar 26, 2013, 4:45:54 AM3/26/13
to pi...@googlegroups.com
Hi Anton

Thanks for this, and I'm working to make sure that this doesn't happen again here in the company, that we miss the updates of the public repo (by 8 months). We have a copy of piqi on our internal build-server, but it should have been kept up to date!

Thanks

Bart
Reply all
Reply to author
Forward
0 new messages