fix(game): Harmonize SQL query formatting, truncation logging, and DataPack lifecycle#1492
Open
Rushaway wants to merge 2 commits into
Open
fix(game): Harmonize SQL query formatting, truncation logging, and DataPack lifecycle#1492Rushaway wants to merge 2 commits into
Rushaway wants to merge 2 commits into
Conversation
… DataPack lifecycle - replace Escape + Format patterns with DB.Format/SQLiteDB.Format in main and comms - enforce placeholder policy: %!s for internal SQL identifiers/fragments, %s for runtime/user input - add/keep query buffer truncation guards before query execution - standardize truncation diagnostics on LogError across both plugins
rumblefrog
reviewed
Jun 1, 2026
| { | ||
| // The insert was successful so delete the record from the queue | ||
| FormatEx(query, sizeof(query), | ||
| if (SQLiteDB.Format(query, sizeof(query), |
rumblefrog
reviewed
Jun 1, 2026
|
|
||
| char query[4096]; | ||
| Format(query, sizeof(query), | ||
| if (g_hDatabase.Format(query, sizeof(query), |
Member
There was a problem hiding this comment.
ditto, if we should use local db reference?
There was a problem hiding this comment.
Pull request overview
This PR refactors the two SourceBans++ SourceMod plugins to standardize SQL query construction and error handling, primarily by replacing manual escaping + Format/FormatEx patterns with Database.Format/SQLiteDB.Format and adding consistent truncation guards.
Changes:
- Migrated query building to
DB.Format/db.Format/SQLiteDB.Formatwith consistent placeholder usage and truncation checks. - Standardized truncation diagnostics to
LogErrorand increased some query buffer sizes. - Adjusted
DataPackallocation timing in some paths to avoid unnecessary allocation when query formatting fails.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 35 comments.
| File | Description |
|---|---|
| game/addons/sourcemod/scripting/sbpp_main.sp | Reworked multiple ban/unban and queue queries to use DB.Format, added truncation guards, and adjusted some DataPack lifecycle decisions. |
| game/addons/sourcemod/scripting/sbpp_comms.sp | Reworked comms queries to use Database.Format, added truncation guards, and moved DataPack allocation in unblock paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1570
to
+1573
| { | ||
| LogError("Query_UnBlockSelect update query truncated"); | ||
| continue; | ||
| } |
Comment on lines
+1300
to
+1303
| { | ||
| LogError("SelectBanIpCallback insert query truncated"); | ||
| return; | ||
| } |
Comment on lines
+1309
to
+1312
| { | ||
| LogError("SelectBanIpCallback insert query truncated"); | ||
| return; | ||
| } |
Comment on lines
+1517
to
+1520
| { | ||
| LogError("SelectAddbanCallback insert query truncated"); | ||
| return; | ||
| } |
Comment on lines
+1526
to
+1529
| { | ||
| LogError("SelectAddbanCallback insert query truncated"); | ||
| return; | ||
| } |
Comment on lines
+1309
to
+1312
| { | ||
| LogError("SelectBanIpCallback insert query truncated"); | ||
| return; | ||
| } |
Comment on lines
+1517
to
+1520
| { | ||
| LogError("SelectAddbanCallback insert query truncated"); | ||
| return; | ||
| } |
Comment on lines
+1526
to
+1529
| { | ||
| LogError("SelectAddbanCallback insert query truncated"); | ||
| return; | ||
| } |
Comment on lines
+2619
to
+2622
| { | ||
| LogError("UTIL_InsertBan query truncated"); | ||
| return; | ||
| } |
Comment on lines
+2628
to
+2631
| { | ||
| LogError("UTIL_InsertBan query truncated"); | ||
| return; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR updates both SourceBans++ scripting plugins to apply a consistent SQL construction and error-handling pattern.
Updated files:
Key changes:
Motivation and Context
This change improves safety and consistency in SQL handling across plugins:
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
Note: If your PR touches
web/**and this is your firstcontribution to the web panel, the CLA bot will comment within
~30 seconds with one-line sign instructions. You only need to sign
once per repo. See
CLA.mdfor the full text andCONTRIBUTING.mdfor the rationale.