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

502 errors caused by invalid timemap #49

Closed
ikreymer opened this issue Nov 30, 2015 · 1 comment
Closed

502 errors caused by invalid timemap #49

ikreymer opened this issue Nov 30, 2015 · 1 comment
Labels
Milestone

Comments

@ikreymer
Copy link

Presumably this is caused by an invalid timemap, causes the response to 502

panic: runtime error: index out of range

goroutine 6 [running]:
main.extractMementos(0xc820504f00, 0xc820508e10)
        /go/src/github.com/oduwsdl/memgator/main.go:187 +0xd4c
main.fetchTimemap(0xc8200112c0, 0x13, 0xc820017b10, 0x7, 0xc820010f20, 0x13, 0xc82000b3e0, 0x2a, 0xc820010f00, 0x20, ...)
        /go/src/github.com/oduwsdl/memgator/main.go:273 +0x1357
created by main.aggregateTimemap
        /go/src/github.com/oduwsdl/memgator/main.go:374 +0xa0a

goroutine 1 [IO wait]:
@ibnesayeed ibnesayeed added the bug label Nov 30, 2015
@ibnesayeed ibnesayeed added this to the 1.0 milestone Nov 30, 2015
@ibnesayeed
Copy link
Member

This is not necessarily due to an invalid TimeMap, rather it's because of a case that was not taken care of. The panic is raised due to the following lines of the code:

kv := regs["kvaldlm"].Split(attr, 2)
linkmap[kv[0]] = kv[1]

In the above lines, a link attribute is split in name and value (0 and 1 indexes of an array respectively), then the value is added to a dictionary with the name as the key. It is possible that there is an attribute that does not have a value. This style of attributes is common in HTML attributes such as async, readonly, selected, and disabled etc. In such a case, existing code will have nothing for the value of kv[1] which will cause this panic. Here is a test case that illustrates this issue.

However, the fix is simple. We just need to check if the kv slice has at least two elements before assigning it, otherwise ignore the attribute.

@ibnesayeed ibnesayeed modified the milestones: 1.0, 1.0-RC4 Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants