Return bank existence lookup errors to callers

- Make `bank_exists` surface backend/UID resolution failures instead of returning `false`
- Add SQF guard to log and alert on unexpected existence responses
- Prevent duplicate/default bank records after failed lookups
This commit is contained in:
Jacob Schmidt 2026-05-21 22:39:22 -05:00
parent 788ac6da7a
commit aad36ddd8d
2 changed files with 12 additions and 7 deletions

View File

@ -328,6 +328,11 @@ GVAR(BankBaseStore) = compileFinal createHashMapFromArray [
GVAR(BankMessenger) call ["sendAlert", [_uid, "error", _result select [7]]]; GVAR(BankMessenger) call ["sendAlert", [_uid, "error", _result select [7]]];
createHashMap createHashMap
}; };
if !(_result in ["true", "false"]) exitWith {
["ERROR", format ["Bank exists check for %1 returned unexpected response: %2", _uid, _result]] call EFUNC(common,log);
GVAR(BankMessenger) call ["sendAlert", [_uid, "error", "Bank backend returned an unexpected existence response."]];
createHashMap
};
private _finalAccount = createHashMap; private _finalAccount = createHashMap;
private _wasCreated = false; private _wasCreated = false;

View File

@ -548,6 +548,8 @@ pub fn update_bank(call_context: CallContext, key: String, json_update: String)
/// Checks if an bank exists in the database. /// Checks if an bank exists in the database.
/// ///
/// Returns "true" if the bank exists, "false" otherwise. /// Returns "true" if the bank exists, "false" otherwise.
/// Backend failures are returned as errors so callers do not confuse a failed
/// lookup with a missing account and create duplicate/default records.
pub fn bank_exists(call_context: CallContext, key: String) -> String { pub fn bank_exists(call_context: CallContext, key: String) -> String {
log( log(
"bank", "bank",
@ -561,12 +563,9 @@ pub fn bank_exists(call_context: CallContext, key: String) -> String {
uid uid
} }
None => { None => {
log( let error_msg = format!("Error: Failed to resolve UID for key: {}", key);
"bank", log("bank", "ERROR", &error_msg);
"WARN", return error_msg;
&format!("Failed to resolve UID for key: {}", key),
);
return "false".to_string();
} }
}; };
@ -580,12 +579,13 @@ pub fn bank_exists(call_context: CallContext, key: String) -> String {
exists.to_string() exists.to_string()
} }
Err(e) => { Err(e) => {
let error_msg = format!("Error: {}", e);
log( log(
"bank", "bank",
"ERROR", "ERROR",
&format!("Failed to check if bank '{}' exists: {}", resolved_uid, e), &format!("Failed to check if bank '{}' exists: {}", resolved_uid, e),
); );
"false".to_string() error_msg
} }
} }
} }