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

ChatReader: Do not attempt to look for the Author name while the payload is malformed. #640

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Core/Chat/ChatReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ public void Update(IAddonDataProvider reader)

string text = sb.ToString().ToLowerInvariant();
sb.Clear();

int firstSpaceIdx = text.AsSpan().IndexOf(' ');
string author = text.AsSpan(0, firstSpaceIdx).ToString();
string msg = text.AsSpan(firstSpaceIdx + 1).ToString();

ChatMessageEntry entry = new(DateTime.Now, type, author, msg);
Messages.Add(entry);
logger.LogInformation(entry.ToString());
Copy link
Owner

Choose a reason for hiding this comment

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

Can you prove logs about this issue ?

Copy link
Author

Choose a reason for hiding this comment

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

[20:36:45:267 E] Specified argument was out of the range of valid values. (Parameter 'start')
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'start')
at Core.ChatReader.Update(IAddonDataProvider reader) in C:\Users\liona\Downloads\dev\WowClassicGrindBot-dev\Core\Chat\ChatReader.cs:line 43
at Core.AddonReader.Update() in C:\Users\liona\Downloads\dev\WowClassicGrindBot-dev\Core\Addon\AddonReader.cs:line 73
at Core.BotController.AddonThread() in C:\Users\liona\Downloads\dev\WowClassicGrindBot-dev\Core\BotController.cs:line 156
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'start')
at Core.ChatReader.Update(IAddonDataProvider reader) in C:\Users\liona\Downloads\dev\WowClassicGrindBot-dev\Core\Chat\ChatReader.cs:line 43
at Core.AddonReader.Update() in C:\Users\liona\Downloads\dev\WowClassicGrindBot-dev\Core\Addon\AddonReader.cs:line 73
at Core.BotController.AddonThread() in C:\Users\liona\Downloads\dev\WowClassicGrindBot-dev\Core\BotController.cs:line 156
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

try
{
int firstSpaceIdx = text.AsSpan().IndexOf(' ');
string author = text.AsSpan(0, firstSpaceIdx).ToString();
string msg = text.AsSpan(firstSpaceIdx + 1).ToString();

ChatMessageEntry entry = new(DateTime.Now, type, author, msg);
Messages.Add(entry);
logger.LogInformation(entry.ToString());
} catch (Exception e)
{
logger.LogError("ChatEntryError: " + e.ToString());
}
}
}