application-services icon indicating copy to clipboard operation
application-services copied to clipboard

placesQueryHistoryMetadata(): LIKE or GLOB pattern too complex

Open pocmo opened this issue 2 years ago • 6 comments

mozilla.components.support.rustlog.RustErrorException: places::ffi - Unexpected error: SqlError(SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("LIKE or GLOB pattern too complex")))
    at mozilla.components.support.rustlog.CrashReporterOnLog.invoke(RustLog.kt:9)
    at mozilla.appservices.rustlog.RawLogCallbackImpl.invoke(RustLogAdapter.kt:3)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:11)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:1)
    at com.sun.jna.Native.invokeStructure(Native.java)
    at com.sun.jna.Native.invokeStructure(Native.java:3)
    at com.sun.jna.Function.invoke(Function.java:65)
    at com.sun.jna.Function.invoke(Function.java:22)
    at com.sun.jna.Library$Handler.invoke(Library.java:32)
    at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
    at $Proxy14.places_219d_places_query_history_metadata
    at mozilla.appservices.places.uniffi.PlacesKt.placesQueryHistoryMetadata(places.kt:3)
    at mozilla.appservices.places.PlacesReaderConnection.queryHistoryMetadata$suspendImpl(PlacesConnection.kt:4)
    at mozilla.appservices.places.PlacesReaderConnection.queryHistoryMetadata
    at mozilla.components.browser.storage.sync.PlacesHistoryStorage.queryHistoryMetadata$suspendImpl(PlacesHistoryStorage.kt:5)
    at mozilla.components.browser.storage.sync.PlacesHistoryStorage.queryHistoryMetadata
    at mozilla.components.feature.awesomebar.provider.CombinedHistorySuggestionProvider$onInputChanged$2$metadataSuggestionsAsync$1.invokeSuspend(CombinedHistorySuggestionProvider.kt:8)

Fenix: https://github.com/mozilla-mobile/fenix/issues/22416 Sentry: https://sentry.prod.mozaws.net/operations/firefox-nightly/issues/14728348/

┆Issue is synchronized with this Jira Bug ┆epic: MR2 History Metadata Sync support ┆sprintEndDate: 2021-11-24

pocmo avatar Nov 11 '21 14:11 pocmo

CC @grigoryk

pocmo avatar Nov 11 '21 14:11 pocmo

Looking at https://www.sqlite.org/limits.html#max_like_pattern_length, I suspect the problem is that the query param here is > 50k.

mhammond avatar Nov 12 '21 05:11 mhammond

Wow, interesting. We definitely don't have safeguards against this in the metadata storage queries. I also wonder if there's some bug upstream of the queries, e.g. it's hard to imagine a legit scenario where that query param is so large...

grigoryk avatar Nov 15 '21 20:11 grigoryk

It looks like HistoryMetadataSuggestionProvider takes the entire awesomebar contents and feeds it into this API. So isn't it possible that some extremely long URL is being edited? Places handles URLs up to 64k long (like desktop does)

mhammond avatar Nov 16 '21 03:11 mhammond

Good old images in data: URIs maybe?

pocmo avatar Nov 16 '21 12:11 pocmo

A while ago on Desktop, we saw some massive "normal" URLs, with insanely long params - eg, you could something like a data: URL, but encoded as a http url with the data in a param.

The only reason I raise this is that for this API in particular, it's not clear to me that url params make sense?

mhammond avatar Nov 16 '21 23:11 mhammond

Moved to bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1866544

Change performed by the Move to Bugzilla add-on.

mhammond avatar Nov 24 '23 15:11 mhammond