Flow.Launcher icon indicating copy to clipboard operation
Flow.Launcher copied to clipboard

BUG: Windows search index throws exception when searching

Open Phoenix- opened this issue 3 years ago • 18 comments

Checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I am using the latest version of Flow Launcher.

Problem Description

Hey. Got a problem similar to https://github.com/Flow-Launcher/Flow.Launcher/issues/1630 Flow shows message 'Flow.Launcher.Plugin.Explorer.Exceptions.SearchException: Invalid URI: The Authority/Host could not be parsed.' as first result

Debugged it and I'm seeing that encodedFragmentPath var in WindowsIndex.cs:59 is containing only 'file:' and URI ctor fails. Did not dig deeper. Can do if needed, tho. Possible quick fix is just to wrap every result parsing with try-catch and just ignore invalid results, but thats a no-brainer from someone without knowledge on what's going on there.

Complete exception stack: WindowsIndex Search Exception: Flow.Launcher.Plugin.Explorer.Exceptions.SearchException: Invalid URI: The Authority/Host could not be parsed. ---> System.UriFormatException: Invalid URI: The Authority/Host could not be parsed. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions) at Flow.Launcher.Plugin.Explorer.Search.WindowsIndex.WindowsIndex.ExecuteWindowsIndexSearchAsync(String indexQueryString, String connectionString, CancellationToken token)+MoveNext() in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Search\WindowsIndex\WindowsIndex.cs:line 70 at Flow.Launcher.Plugin.Explorer.Search.WindowsIndex.WindowsIndex.ExecuteWindowsIndexSearchAsync(String indexQueryString, String connectionString, CancellationToken token)+MoveNext() in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Search\WindowsIndex\WindowsIndex.cs:line 70 at Flow.Launcher.Plugin.Explorer.Search.WindowsIndex.WindowsIndex.ExecuteWindowsIndexSearchAsync(String indexQueryString, String connectionString, CancellationToken token)+MoveNext() in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Search\WindowsIndex\WindowsIndex.cs:line 70 at Flow.Launcher.Plugin.Explorer.Search.WindowsIndex.WindowsIndex.ExecuteWindowsIndexSearchAsync(String indexQueryString, String connectionString, CancellationToken token)+MoveNext() in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Search\WindowsIndex\WindowsIndex.cs:line 70 at Flow.Launcher.Plugin.Explorer.Search.WindowsIndex.WindowsIndex.ExecuteWindowsIndexSearchAsync(String indexQueryString, String connectionString, CancellationToken token)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult() at Flow.Launcher.Plugin.Explorer.Search.SearchManager.SearchAsync(Query query, CancellationToken token) in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Search\SearchManager.cs:line 129 at Flow.Launcher.Plugin.Explorer.Search.SearchManager.SearchAsync(Query query, CancellationToken token) in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Search\SearchManager.cs:line 129 --- End of inner exception stack trace --- at Flow.Launcher.Plugin.Explorer.Search.SearchManager.SearchAsync(Query query, CancellationToken token) in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Search\SearchManager.cs:line 129 at Flow.Launcher.Plugin.Explorer.Main.QueryAsync(Query query, CancellationToken token) in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.Explorer\Main.cs:line 88

To Reproduce

  1. Setup windows search SOMEHOW
  2. enable corresponding plugin, set everything to windows search.
  3. observe.

Screenshots

image

Flow Launcher Version

1.16.0

Windows Build Number

22H2 22621.1992

Error Log

Found nothing of interest there

Phoenix- avatar Aug 06 '23 17:08 Phoenix-

Can you check for me please, if the Windows Search service is enabled/disabled or non-existent on your machine?

jjw24 avatar Aug 07 '23 02:08 jjw24

Yes, windows search is enabled in extended mode, all drives are indexed.

Phoenix- avatar Aug 07 '23 09:08 Phoenix-

This error should only happen if Windows Search service is non-existent if I remember correctly. So you are still getting this error even when enabled ?

jjw24 avatar Aug 07 '23 09:08 jjw24

Yep, windows search service seems to work. I changed the code around like this

                SearchResult result;
                try
                {
                    var path = new Uri(encodedFragmentPath).LocalPath;
                    result = new SearchResult
                    {
                        FullPath = path,
                        Type = dataReader.GetString(2) == "Directory" ? ResultType.Folder : ResultType.File,
                        WindowsIndexed = true
                    };
                }
                catch
                {
                    continue;
                }

                yield return result;

and now search yields results.

Phoenix- avatar Aug 07 '23 09:08 Phoenix-

Under what circumstance caused encodedFragmentPath to be half complete though? It shouldn't be just file:

jjw24 avatar Aug 07 '23 09:08 jjw24

Cant pinpoint exact reason for invalid results. Searching for anything common like '1' yields lots of matches and some of them are invalid(file:). I have a strange feeling that is somehow fails around Starcraft-1 and Warcraft-3 maps with names like (4)Ruins of the Ancients.scm. No idea what's wrong with them.

Phoenix- avatar Aug 07 '23 10:08 Phoenix-

What's encodedFragmentPath when you catch the exception?

jjw24 avatar Aug 07 '23 10:08 jjw24

file: image

Phoenix- avatar Aug 07 '23 10:08 Phoenix-

There are multiple 'file:' results. All of them are located around valid results of Starcraft maps.

"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/BroodWar/(2)Astral Balance.scm"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/ladder/Season 10/(3)Ascension_1.0.scx"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/ladder/2018Season1/(3)Aztec 2.1.scx"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/ladder/2018Season2/(3)Aztec 2.1_iCCup.scx"
"file:E:/From Tecra/Warcraft III/Maps/(4)Adrenaline.w3m"
"file:E:/From Tecra/Warcraft III/Maps/FrozenThrone/(4)Adrenaline.w3x"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/ladder/Season 11/(4)Allegro_1.1b.scx"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/(4)Alpha Draconis.scm"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/BroodWar/(4)Archipelago.scm"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/BroodWar/(4)Arctic Station.scx"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/ladder/(4)Ashrigo.scm"
"file:E:/From Tecra/Warcraft III/Maps/FrozenThrone/(4)Avalanche.w3x"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/BroodWar/WebMaps/(4)Catwalk Alley.scm"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/ladder/2018Season2/(4)In the Way of an Eddy.scx"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/(4)Ruins of the Ancients.scm"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/BroodWar/(4)Space Atoll.scm"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/ladder/(6)Acropolis.scm"
"file:"
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
"file:C:/Games/StarCraft/Maps/BroodWar/(6)Across the Cape.scm"

I dont see any 'file:' results in other directories

Phoenix- avatar Aug 07 '23 10:08 Phoenix-

Can you try searching for files in one of those folders to see if you can narrow down the list

jjw24 avatar Aug 07 '23 10:08 jjw24

If I understand it correctly - never worked with WS API - GetValue(0) is file name and GetValue(1) is the full path. when I get 'file:' for GetValue(1) I get correct file name for GetValue(0). Furthermore, next result yields same name with correct path. Looks like that WS DB is somehow corrupted. Or maybe some implementation weirdness.

Phoenix- avatar Aug 07 '23 10:08 Phoenix-

You have checks for DBNull in GetValue(0) or GetValue(1). Maybe just extend them to reject empty path?

Phoenix- avatar Aug 07 '23 10:08 Phoenix-

GetValue(0) is file name and GetValue(1) is the full path.

Yes, and GetValue(2) would be the type of path.

when I get 'file:' for GetValue(1) I get correct file name for GetValue(0).

Are you saying the ones you get empty path on actual has a file name from GetValue(0)?

jjw24 avatar Aug 07 '23 11:08 jjw24

Furthermore, next result yields same name with correct path. Looks like that WS DB is somehow corrupted. Or maybe some implementation weirdness.

You have checks for DBNull in GetValue(0) or GetValue(1). Maybe just extend them to reject empty path?

Potentially could be if it is what you are saying, which means rebuilding index could solve this issue as a workaround (worth confirming afterwards). If it is the case then yes extend the checks to reject empty path would be the right fix.

I wasn't sure initially what's causing the empty path, but if it's from db corruption seeing you get duplicate entries of the same name but one with and one without path, then we should extend the check to cover this.

jjw24 avatar Aug 07 '23 11:08 jjw24

Are you saying the ones you get empty path on actual has a file name from GetValue(0)?

Exactly. Some results come in pairs

  1. Name: '(2)Blue Storm 1.2_iCCup.scx' Path: 'file:'
  2. name '(2)Blue Storm 1.2_iCCup.scx' Path: 'file:C:/blah-blah/(2)Blue Storm 1.2_iCCup.scx'

I wasn't sure initially what's causing the empty path, but if it's from db corruption seeing you get duplicate entries of the same name but one with and one without path, then we should extend the check to cover this.

Yep. I moved SC folder between drives recently. Since then WS index is updated, so its not an issue of indexing in process. But maybe WS stores deleted entries. Or somehow fails to delete entries? Anyway, I doubt its worth digging into Windows internals. I'd say just ignore anything incorrect and call it a day.

Phoenix- avatar Aug 07 '23 11:08 Phoenix-

Yes agree. Thank you for investigating this.

Could you fire up a pr for this please.

jjw24 avatar Aug 07 '23 12:08 jjw24

Thanks! Filing PR in a moment.

Phoenix- avatar Aug 07 '23 12:08 Phoenix-

Fixed and available in prerelease.

jjw24 avatar Aug 08 '23 02:08 jjw24