add a stack_trace to config validation checking (#73160)

## About The Pull Request

config validation didn't actually throw on invalid configs, thus CI
never caught breaking changes
## Why It's Good For The Game

config should work
This commit is contained in:
Zephyr
2023-02-07 02:05:41 -05:00
committed by GitHub
parent 5cae5910b2
commit bb3947e68f
3 changed files with 31 additions and 7 deletions

View File

@@ -60,6 +60,9 @@
/// An assoc list of words that are soft blocked both IC and OOC to their reasons
var/static/list/soft_shared_filter_reasons
/// A list of configuration errors that occurred during load
var/static/list/configuration_errors
/datum/controller/configuration/proc/admin_reload()
if(IsAdminAdvancedProcCall())
return
@@ -75,6 +78,7 @@
directory = _directory
if(entries)
CRASH("/datum/controller/configuration/Load() called more than once!")
configuration_errors ||= list()
InitEntries()
if(fexists("[directory]/config.txt") && LoadEntries("config.txt") <= 1)
var/list/legacy_configs = list("game_options.txt", "dbconfig.txt", "comms.txt")
@@ -97,6 +101,7 @@
if (Master)
Master.OnConfigLoad()
process_config_errors()
/datum/controller/configuration/proc/full_wipe()
if(IsAdminAdvancedProcCall())
@@ -107,6 +112,7 @@
QDEL_LIST_ASSOC_VAL(maplist)
maplist = null
QDEL_NULL(defaultmap)
configuration_errors?.Cut()
/datum/controller/configuration/Destroy()
full_wipe()
@@ -114,6 +120,16 @@
return ..()
/datum/controller/configuration/proc/log_config_error(error_message)
configuration_errors += error_message
log_config(error_message)
/datum/controller/configuration/proc/process_config_errors()
if(!CONFIG_GET(flag/config_errors_runtime))
return
for(var/error_message in configuration_errors)
stack_trace(error_message)
/datum/controller/configuration/proc/InitEntries()
var/list/_entries = list()
entries = _entries
@@ -128,7 +144,7 @@
var/esname = E.name
var/datum/config_entry/test = _entries[esname]
if(test)
log_config("Error: [test.type] has the same name as [E.type]: [esname]! Not initializing [E.type]!")
log_config_error("Error: [test.type] has the same name as [E.type]: [esname]! Not initializing [E.type]!")
qdel(E)
continue
_entries[esname] = E
@@ -144,7 +160,7 @@
var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename
if(filename_to_test in stack)
log_config("Warning: Config recursion detected ([english_list(stack)]), breaking!")
log_config_error("Warning: Config recursion detected ([english_list(stack)]), breaking!")
return
stack = stack + filename_to_test
@@ -179,7 +195,7 @@
if(entry == "$include")
if(!value)
log_config("Warning: Invalid $include directive: [value]")
log_config_error("Warning: Invalid $include directive: [value]")
else
LoadEntries(value, stack)
++.
@@ -189,7 +205,7 @@
if (entry == "$reset")
var/datum/config_entry/resetee = _entries[lowertext(value)]
if (!value || !resetee)
log_config("Warning: invalid $reset directive: [value]")
log_config_error("Warning: invalid $reset directive: [value]")
continue
resetee.set_default()
log_config("Reset configured value for [value] to original defaults")
@@ -219,10 +235,12 @@
var/validated = E.ValidateAndSet(value)
if(!validated)
log_config("Failed to validate setting \"[value]\" for [entry]")
var/log_message = "Failed to validate setting \"[value]\" for [entry]"
log_config(log_message)
stack_trace(log_message)
else
if(E.modified && !E.dupes_allowed)
log_config("Duplicate setting for [entry] ([value], [E.resident_file]) detected! Using latest.")
log_config_error("Duplicate setting for [entry] ([value], [E.resident_file]) detected! Using latest.")
E.resident_file = filename

View File

@@ -525,7 +525,7 @@
/datum/config_entry/string/chat_announce_new_game
deprecated_by = /datum/config_entry/string/channel_announce_new_game
/datum/config_entry/flag/chat_announce_new_game/DeprecationUpdate(value)
/datum/config_entry/string/chat_announce_new_game/DeprecationUpdate(value)
return "" //default broadcast
/datum/config_entry/string/channel_announce_new_game
@@ -659,3 +659,6 @@
/datum/config_entry/string/morgue_cadaver_override_species
/datum/config_entry/flag/toast_notification_on_init
/datum/config_entry/flag/config_errors_runtime
default = FALSE