Skip to content

Upgrade fuzzysearch dependency to handle extensions with problematic utf8 characters #31

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

Merged

Conversation

fleskesvor
Copy link
Contributor

When any of the installed extensions have certain utf8 characters in the description of their vsixmanifest, searching fails with the following stacktrace:

2023-12-08 10:55:05.153 [WARN]	<recover.go:18>	panic serving http request (recovered)	{"panic": "runtime error: slice bounds out of range [69:68]"} ...
  "stack": goroutine 41 [running]:
           runtime/debug.Stack()
           	/home/eivind/go/src/runtime/debug/stack.go:24 +0x5e
           github.com/coder/code-marketplace/api.New.Recover.func6.1.1()
           	/home/eivind/Projects/code-marketplace/api/httpmw/recover.go:21 +0xca
           panic({0x910180?, 0xc00013e8a0?})
           	/home/eivind/go/src/runtime/panic.go:914 +0x21f
           golang.org/x/text/transform.String({0xa5bf80, 0xd987c0}, {0xc00014a7d0, 0x44})
           	/home/eivind/go/pkg/mod/golang.org/x/text@v0.4.0/transform/transform.go:650 +0xbb0
           github.com/lithammer/fuzzysearch/fuzzy.stringTransform({0xc00014a7d0, 0x44}, {0xa5bf80?, 0xd987c0?})
           	/home/eivind/go/pkg/mod/github.com/lithammer/fuzzysearch@v1.1.5/fuzzy/fuzzy.go:243 +0x50
           github.com/lithammer/fuzzysearch/fuzzy.match({0xc00012177c?, 0xc0001167f0?}, {0xc00014a7d0, 0x44}, {0xa5bf80, 0xd987c0})
           	/home/eivind/go/pkg/mod/github.com/lithammer/fuzzysearch@v1.1.5/fuzzy/fuzzy.go:57 +0x6b
           github.com/lithammer/fuzzysearch/fuzzy.rankFind({0xc00012177c, 0x4}, {0xc0001663e0?, 0x3, 0x898c20?}, {0xa5bf80, 0xd987c0})
           	/home/eivind/go/pkg/mod/github.com/lithammer/fuzzysearch@v1.1.5/fuzzy/fuzzy.go:200 +0xe7
           github.com/lithammer/fuzzysearch/fuzzy.RankFindFold(...)
           	/home/eivind/go/pkg/mod/github.com/lithammer/fuzzysearch@v1.1.5/fuzzy/fuzzy.go:183
           github.com/coder/code-marketplace/database.getMatches(0xc000156a80, {{0xc00017a900, 0x3, 0x4}, 0x1, 0x32, 0x0, 0x0})
           	/home/eivind/Projects/code-marketplace/database/nodb.go:172 +0x7b6
           github.com/coder/code-marketplace/database.(*NoDB).GetExtensions.func1(0x0?, {0xc000480620, 0x1, 0x1})
           	/home/eivind/Projects/code-marketplace/database/nodb.go:61 +0x65
           github.com/coder/code-marketplace/storage.(*Local).WalkExtensions(0xc00011e000, {0xa5dd08, 0xc000123ef0}, 0xc000128500)
           	/home/eivind/Projects/code-marketplace/storage/local.go:151 +0x6f8
           github.com/coder/code-marketplace/database.(*NoDB).GetExtensions(0xc00033a150, {0xa5dd08, 0xc000123ef0}, {{0xc00017a900, 0x3, 0x4}, 0x1, 0x32, 0x0, 0x0}, ...)
           	/home/eivind/Projects/code-marketplace/database/nodb.go:59 +0x144
           github.com/coder/code-marketplace/api.(*API).extensionQuery(0xc000313700, {0xa5cf50, 0xc00017f680}, 0xc00012f000)
           	/home/eivind/Projects/code-marketplace/api/api.go:189 +0x6f3
           net/http.HandlerFunc.ServeHTTP(0x8c0b00?, {0xa5cf50?, 0xc00017f680?}, 0xc000179355?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/go-chi/chi/v5.(*Mux).routeHTTP(0xc0002e3260, {0xa5cf50, 0xc00017f680}, 0xc00012f000)
           	/home/eivind/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/mux.go:442 +0x207
           net/http.HandlerFunc.ServeHTTP(0xc000116020?, {0xa5cf50?, 0xc00017f680?}, 0x1?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/coder/code-marketplace/api.New.Logger.func7.1({0xa5ce30?, 0xc00013ae00}, 0xc00012f000)
           	/home/eivind/Projects/code-marketplace/api/httpmw/logger.go:24 +0x3c3
           net/http.HandlerFunc.ServeHTTP(0x0?, {0xa5ce30?, 0xc00013ae00?}, 0xd?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/coder/code-marketplace/api/httpmw.AttachBuildInfo.func1({0xa5ce30, 0xc00013ae00}, 0x30?)
           	/home/eivind/Projects/code-marketplace/api/httpmw/buildinfo.go:13 +0x15e
           net/http.HandlerFunc.ServeHTTP(0x0?, {0xa5ce30?, 0xc00013ae00?}, 0x30?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/coder/code-marketplace/api.New.Recover.func6.1({0xa5ce30?, 0xc00013ae00?}, 0xc000134901?)
           	/home/eivind/Projects/code-marketplace/api/httpmw/recover.go:39 +0xcf
           net/http.HandlerFunc.ServeHTTP(0x902bc0?, {0xa5ce30?, 0xc00013ae00?}, 0x12?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/coder/code-marketplace/api/httpmw.AttachRequestID.func1({0xa5ce30, 0xc00013ae00}, 0xc00012ef00)
           	/home/eivind/Projects/code-marketplace/api/httpmw/requestid.go:32 +0x39d
           net/http.HandlerFunc.ServeHTTP(0xc0002f75c0?, {0xa5ce30?, 0xc00013ae00?}, 0x0?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/go-chi/chi/v5/middleware.GetHead.func1({0xa5ce30?, 0xc00013ae00?}, 0xc00006b970?)
           	/home/eivind/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/middleware/get_head.go:37 +0x1dc
           net/http.HandlerFunc.ServeHTTP(0xc0002f75f0?, {0xa5ce30?, 0xc00013ae00?}, 0xc0001216f8?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/go-chi/httprate.(*rateLimiter).Handler-fm.(*rateLimiter).Handler.func1({0xa5ce30, 0xc00013ae00}, 0xc000134a28?)
           	/home/eivind/go/pkg/mod/github.com/go-chi/httprate@v0.7.0/limiter.go:124 +0x3bf
           net/http.HandlerFunc.ServeHTTP(0xc00034e1e0?, {0xa5ce30?, 0xc00013ae00?}, 0xc00012ef00?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/go-chi/cors.(*Cors).Handler-fm.(*Cors).Handler.func1({0xa5ce30, 0xc00013ae00}, 0xc00012ef00)
           	/home/eivind/go/pkg/mod/github.com/go-chi/cors@v1.2.1/cors.go:228 +0x17e
           net/http.HandlerFunc.ServeHTTP(0xa5dd40?, {0xa5ce30?, 0xc00013ae00?}, 0xd59360?)
           	/home/eivind/go/src/net/http/server.go:2136 +0x29
           github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0xc0002e3260, {0xa5ce30, 0xc00013ae00}, 0xc00012ee00)
           	/home/eivind/go/pkg/mod/github.com/go-chi/chi/v5@v5.0.7/mux.go:88 +0x315
           net/http.serverHandler.ServeHTTP({0xa5b8a0?}, {0xa5ce30?, 0xc00013ae00?}, 0x6?)
           	/home/eivind/go/src/net/http/server.go:2938 +0x8e
           net/http.(*conn).serve(0xc000318bd0, {0xa5dd08, 0xc000122180})
           	/home/eivind/go/src/net/http/server.go:2009 +0x5f4
           created by net/http.(*Server).Serve in goroutine 34
           	/home/eivind/go/src/net/http/server.go:3086 +0x5cb

This error is related to lithammer/fuzzysearch#54, which was fixed by lithammer/fuzzysearch#55 and released in version 1.1.8 of the library.

The error can be triggered by editing the Description tag in extension.vsixmanifest of any installed extension to e.g. include the character Ⱦ.

Upgrading the dependency fixes the problem with searching installed extensions.

Copy link

github-actions bot commented Dec 8, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@fleskesvor
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you!

@code-asher code-asher merged commit 4bef2c5 into coder:main Dec 8, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
@code-asher
Copy link
Member

Released in v2.0.1.

@fleskesvor fleskesvor deleted the fix/fuzzysearch-utf8-replacement-character branch December 8, 2023 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants