the-hideout / TarkovMonitor

Monitor Tarkov log files to help track progress, queues, and groups
GNU General Public License v3.0
91 stars 16 forks source link

Error starting game watcher: String '' was not recognized as a valid DateTime. #65

Closed shzferreira closed 3 months ago

shzferreira commented 5 months ago

Hi guys, I've tried running multiple versions of the software to see if it would work but I get the same message. As a result I am unable to get the app to read my logs and update in tarkov tracker. I also am Unable to read past Logs, it does let me click on it but it stays "loading" for a long time. By that I mean, i've let it trying to read it overnight (over 12hours).

I Think it is worth mentioning the version 1.3 said it could not find the folder "C:\Battlestate Games\EFT\Logs" when it is clearly there.

Here is the error in the "Dashboard" section of the app Error starting game watcher: String '' was not recognized as a valid DateTime. at TarkovMonitor.GameWatcher.GetLatestLogFolder() in TarkovMonitor\GameWatcher.cs:line 616 at TarkovMonitor.GameWatcher.Start() in TarkovMonitor\GameWatcher.cs:line 221

Furthermore, I tried changing the logs location in the EFT launcher to "C:\Battlestate Games\EFT\NewLogs" so that I could change the pathway within tarkov monitor to the same but when I select it it comes up with the error shown in the picture attached.

Any help would be much appreciates as I've even tried going in the "GameWatcher" CS file but could not fix the issue.

image_2024-04-09_174121430

shzferreira commented 5 months ago

If I click on "Details" on that error message in the picture, this comes up:

** Exception Text ** System.FormatException: String '' was not recognized as a valid DateTime. at TarkovMonitor.GameWatcher.GetLatestLogFolder() in TarkovMonitor\GameWatcher.cs:line 616 at TarkovMonitor.GameWatcher.set_LogsPath(String value) in TarkovMonitor\GameWatcher.cs:line 46 at TarkovMonitor.MainBlazorUI.<.ctor>b6_0(Object sender, PropertyChangedEventArgs e) in TarkovMonitor\MainBlazorUI.cs:line 89 at System.Configuration.ApplicationSettingsBase.OnPropertyChanged(Object sender, PropertyChangedEventArgs e) at System.Configuration.ApplicationSettingsBase.set_Item(String propertyName, Object value) at TarkovMonitor.Properties.Settings.set_customLogsPath(String value) in TarkovMonitor\Properties\Settings.Designer.cs:line 250 at TarkovMonitor.Blazor.Pages.Settings.Settings.set_CustomLogsFolder(String value) in TarkovMonitor\Blazor\Pages\Settings\Settings.razor:line 542 at TarkovMonitor.Blazor.Pages.Settings.Settings.CustomLogsFolderClick() in TarkovMonitor\Blazor\Pages\Settings\Settings.razor:line 554 at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[T](MulticastDelegate delegate, T arg) at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync(Object arg) at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg) at Microsoft.AspNetCore.Components.EventCallback`1.InvokeAsync(TValue arg) at MudBlazor.MudBaseButton.OnClickHandler(MouseEventArgs ev) at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) at Microsoft.AspNetCore.Components.WebView.IpcSender.<>cDisplayClass9_0.b1() at Microsoft.AspNetCore.Components.WebView.WindowsForms.WindowsFormsDispatcher.InvokeAsync(Action workItem) at Microsoft.AspNetCore.Components.WebView.WindowsForms.WindowsFormsDispatcher.<>c.<.cctor>b8_0(Exception exception)

Razzmatazzz commented 5 months ago

I'm confused about how you changed the game logs location as I don't see that option in my launcher.

When you start the app, are there any messages about errors getting the logs path? The logs path is found via the registry entries for the game install location. If these registry entries are missing for any reason, it will not be able to locate the logs path.

shzferreira commented 5 months ago

No, I have not changed the game logs location. I created a new folder and copied all the logs I had already in my original tarkov/logs folder into it, then when I tried to change the logs location within TarkovTracker, I get the error in the picture. I only tried this in case the app was unable to read the original tarkov/logs folder, but it seems it's a different issue preventing it from accessing the folder I guess?

How do I check if the registry entries are not missing?

Razzmatazzz commented 5 months ago

The registy entry is at: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov and the key is InstallLocation.

I mistakenly thought you changed the game's logs folders in the launcher when you said "Furthermore, I tried changing the logs location in the EFT launcher to "C:\Battlestate Games\EFT\NewLogs" so that I could change the pathway within tarkov monitor to the same but when I select it it comes up with the error shown in the picture attached." But now I understand you didn't change anything in the EFT launcher, but instead copied your Logs folder to NewLogs and then tried setting TarkovMonitor to use that folder.

My best guess at this point is either Tarkov Monitor lacks permissions to access the C:\Battlestate Games\EFT folder (and all subfolders) or the registry entry is missing.

shzferreira commented 5 months ago

Thanks for getting back to me! The registry InstallLocation is "C:\Battlestate Games\EFT" which seems to be correct. I've tried running Tarkov Monitor as admin, still getting the same error :( Any other possible issues?

Razzmatazzz commented 5 months ago

I'm having trouble thinking of what else could cause the app to fail to find a folder that clearly exists. Is there anything unusual or unique about your install or setup?

shzferreira commented 5 months ago

Not really, i've got eft installed here: C:\Battlestate Games\EFT. And the Tarkov Monitor I've extracted here: C:\Users\Ricardo\Desktop\TARK\TarkMonitor The weird thing is, I've used this app during the last wipe along tarkovtracker & rat scanner and did not have any issues with it. I have not since uninstalled EFT, just updated it as well as tarkov Monitor for this wipe. And as i mentioned in the first post, I've tried using previous versions of the TarkMonitor but still not able to read logs. It's very strange

Razzmatazzz commented 5 months ago

Have you tried using the same version of Tarkov Monitor that worked for you last wipe? If that still doesn't work, then it really sounds like something changed with your system.

logger24 commented 5 months ago

Slightly on topic, off topic, but there's some unsafe regular expression code around there. Won't solve the issue, but fwiw:

GameWatcher.cs: Line 616, Line 453, etc.

var dateTimeString = Regex.Match(logFolder, @"log_(?<timestamp>\d+\.\d+\.\d+_\d+-\d+-\d+)").Groups["timestamp"].Value;

Lacks gracefully fail or be handled accordingly, while assuming a match, group and value were found or exist.

For reference:

var dateTimeString = Regex.Match(logFolder, @"log_(?<timestamp>\d+\.\d+\.\d+_\d+-\d+-\d+)");

if (dateTimeString.Success)
{
    // RegEx match success

    var logDate;

    if (dateTimeString.Groups["timestamp"].Success)
    {
        if (DateTime.TryParseExact(dateTimeString.Groups["timestamp"].Value;, "yyyy.MM.dd_H-mm-ss", 
            System.Globalization.CultureInfo.InvariantCulture,
                DateTimeStyles.None, out logDate))
        {
            // Success on ParseExact of matched date
            // logDate value set during TryParseExact
        }
        else
        {
            // Failure to ParseExact on matched date
            // Not a date.
        }
    }
    else
    {
        // Failure matching RegEx group name
        // Group doesn't exist.
    }
}
else
{
    // On RegEx failure to match
    // RegEx returned no matches
}

In regards to the topic though, instead of throwing exceptions or returning empty strings on failure, the program would benefit from a log file of its own for users to send in to pinpoint where the failure is exactly. If a user alters the logs location and it results in a failure, the program should try to gracefully auto-correct instead of throwing exceptions and hard crashing, or utilizing try/catch where catch is left empty.

Just my two cents, so feel free to disregard the unsolicited comment. It would just lead to a lot less back and forth and guess work. I'm sure you're right that this user's configuration is an issue, but a program log would result in a faster solution imo.

Side note: This could be an issue with installing directly into C:\ and could be an ownership issue which would most likely either deny access to folders and files, even preventing them from being seen, and I can't remember if BSG does this by default, but it's a terrible practice nevertheless (Put mine on a separate drive for games), but worth looking into since their account might be configured differently; denying access, although they state it working previously, something could have changed; requiring a work around internally avoiding forcing administrator. A log file would catch all of these things, even if that's not the case. Albeit rusty, I seem to recall running into similar issues ages ago using the file access methods you do, in situations like this, and it wasn't exactly verbose when it happened.

Razzmatazzz commented 5 months ago

@logger24 It seems very unlikely that regex would ever fail, but you're right there should be a check in case it does.

And, yes, the app could benefit from keeping a log of its own. If that's something you'd like to implement and submit a PR for, we greatly appreciate PRs!

logger24 commented 5 months ago

@Razzmatazzz Understood, but I've had my fair share of beatings over the head for both using it and also not handling a failure gracefully. I only quickly glanced at the source and the error provided; if it can't parse an empty string as a date, then I'd assume the regex failed; not because it was bad, but because of a compounding issue that lead to it being unable to, and not being caught. Either way I'm curious about this issue and resolving it. I'll spend some time reading through all of the source and if I think I can contribute for the better, I'd be more than happy to, and I digress before derailing this thread.

Razzmatazzz commented 3 months ago

@shzferreira have you continued to have these problems with the latest version? I included some error handling that should help things work better.