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

Parser fails to parse device_parsers.brand_replacement/model_replacement #6

Closed
lamielle opened this issue Feb 3, 2015 · 2 comments
Closed

Comments

@lamielle
Copy link

lamielle commented Feb 3, 2015

The Go parser fails to parse the current version of the regexes.yaml file in ua-parser/uap-core. Specifically, there are brand_replacement and model_replacement fields in the current yaml that have no equivalent in the DevicePattern struct.

Attempting to parse the yaml yields the following stack trace snippet:

panic: reflect: call of reflect.Value.SetString on zero Value

goroutine 11 [running]:
reflect.flag.mustBeAssignable(0x0)
        /usr/local/Cellar/go/1.4.1/libexec/src/reflect/value.go:215 +0xa1
reflect.Value.SetString(0x0, 0x0, 0x0, 0xc208108bfa, 0x1)
        /usr/local/Cellar/go/1.4.1/libexec/src/reflect/value.go:1476 +0x28
github.com/ua-parser/uap-go/uaparser.ToStruct(0xc208248000, 0x23b, 0x23b, 0x418000, 0xc208165290, 0xc208257f00)
        <redacted>/src/github.com/ua-parser/uap-go/uaparser/parser.go:41 +0x2b9
github.com/ua-parser/uap-go/uaparser.func·003()
        <redacted>/src/github.com/ua-parser/uap-go/uaparser/parser.go:100 +0x141
created by github.com/ua-parser/uap-go/uaparser.New
        <redacted>/src/github.com/ua-parser/uap-go/uaparser/parser.go:107 +0x694

I added the following log line at line 42 in parser.go:

log.Printf("%v,%v GetExportedName(%v)=%v FieldByName=%v", key, value, key, GetExportedName(key), structVal.FieldByName(GetExportedName(key)))

and that yielded a bunch of output, the last of which indicates the missing field in the DevicePattern struct:

2015/02/03 14:26:36 regex_flag,i GetExportedName(regex_flag)=RegexFlag FieldByName=<invalid Value>

So at a minimum the fix is to add a filter for these two fields to unchoke the parser. Even better would be to extend support for these two additional fields in device_parsers.

@justinruggles
Copy link
Contributor

Any update on this? It would be nice to be able to use the latest uap-core with uap-go

@elsigh
Copy link
Contributor

elsigh commented Jul 1, 2015

I just encountered it as well. You can always write a PR btw ;-0 soooo.. I'm gonna do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants