-
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Map Access Exceptions Causing Server Crashes On Invalid Requests #148
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
Fix Map Access Exceptions Causing Server Crashes On Invalid Requests #148
Conversation
Co-authored-by: clauspruefer <17313789+clauspruefer@users.noreply.github.com>
|
@copilot All |
Co-authored-by: clauspruefer <17313789+clauspruefer@users.noreply.github.com>
…ently Co-authored-by: clauspruefer <17313789+clauspruefer@users.noreply.github.com>
You're absolutely correct. I've updated all remaining Changes in commit
All map accesses now verify key existence with Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Please also add an issue for writing "Invalid Requests" Integration Tests. |
clauspruefer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets give a try.
I don't have the ability to create GitHub issues directly. However, I can help you draft the issue content: Title: Add Integration Tests for Invalid Request Handling Description:
These tests should verify that:
Labels: testing, enhancement You can create this issue in the repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes multiple map access exceptions that were causing server crashes by replacing unsafe .at() calls with safe access patterns. The changes ensure the server handles missing map keys gracefully instead of crashing when receiving invalid requests.
- Replaced all
.at()map access calls with safefind()+ validation oroperator[]aftercontains()check - Added proper error handling and logging for missing map keys
- Implemented 404 response for non-existent virtual hosts instead of crashing
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ThreadHandler.cpp | Fixed Headers, Namespaces, and ProcessRequestsIndex map access with proper validation and 404 handling |
| src/ResultOrder.cpp | Replaced unsafe map access with find() checks and proper error handling |
| src/ResultProcessor.cpp | Added safe access pattern for VHostOffsetsPrecalc map |
| src/Filesystem.cpp | Fixed MimeRelations and FilesExtended map access with fallback values |
| src/ClientHandler.cpp | Replaced .at() with operator[] after contains() check |
| src/ASRequestHandler.cpp | Replaced .at() calls with direct member access and operator[] |
| src/ASProcessHandler.cpp | Added safe access pattern for VHostOffsetsPrecalc map |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Fix Multiple Map Access Exceptions
.at()map access points that can throw exceptionsSummary
Successfully removed ALL unsafe
.at()calls that could crash the server. Now using consistent safe access patterns:.find()before accessing with proper null checksoperator[]only after.contains()check or within verified context[]for vector access after bounds validationThe server is now completely resilient to missing map keys and will handle errors gracefully instead of crashing.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.