Night Config Fixes [Forge & Fabric]

Night Config Fixes [Forge & Fabric]

19M Downloads

[Bug]: Mod Config Files are corrected wrong after random restarts

iMex6K opened this issue ยท 14 comments

commented

Mod Loader (Required)

Forge

Minecraft Version (Required)

1.19.2

Mod Version (Required)

NightConfigFixes-v4.0.2-1.19.2-Forge

Notes (Required)

Hi,

it seems like there is a bug with this mod version that is used in BMC3 v13.

Config Files of some Mods are set so some random default values, that even are not in the files in the folger "defaultconfigs".

Example:

[01Mar2023 14:32:07.355] [Thread-0/WARN] [fuzs.nightconfigfixes.config.CheckedConfigFileTypeHandler/CONFIG]: Configuration file /home/mch/multicraft/servers/server240349/config/backpacked-common.toml is not correct. Correcting

In this file "backpackInventorySize" is set to 1 in this case.

In the defaultconfig it is "backpackInventorySize = 3".

When i change the config in "/config" to 3, its working at one serverstart. But after another or maybe 2 its set back to 1 again.

This happens not on every restart but i can say every 2-3 restarts of the server.

The support of BMC and the support of bisecthosting cant help me in this case. The DEV of BMC told me to create an issue here.

This happens to multiple mods, even mods where i didnt do any changes and also mods that are not in the pack like "Chunk+Pregenerator-1.19-4.1.1"

There are multiple .bak files that are generated.

regards
iMex

latest.log (Optional)

No response

commented

Hey there, thanks for the report. This is a bit to unpack, so here we go:

This essentially comes from a design flaw/oversight within Forge's config system related to configs in defaultconfigs.

The problem is configs in the defaultconfigs directory are only used when the config is first created (meaning the file is completely absent in .minecaft/config or in .minecraft/saves/WORLD_NAME/serverconfig). In that case the default file from defaultconfigs is simply copied over.

In your case though, the config watcher finds some issues with your already existing file in .minecaft/config which is indicated by this line (note that this part is from Forge, I only had to copy that piece of code to get Night Config Fixes working):

[01Mar2023 14:32:07.355] [Thread-0/WARN] [fuzs.nightconfigfixes.config.CheckedConfigFileTypeHandler/CONFIG]: Configuration file /home/mch/multicraft/servers/server240349/config/backpacked-common.toml is not correct. Correcting

In that case, and that's the reason for the behavior you are seeing, Forge does NOT load the config from defaultconfigs and restores the value from there. Instead the default value defined in code by the mod the config is from is used. The reason for this is that not the whole config is restored, but only the problematic options (might still be the whole file, but must not).

There are a lot of reasons why such a correction can happen, like:

  • An invalid value for an option which is reset
  • Missing options which are added
  • Options that no longer exist which are removed
  • Or even just something being weird with the file and preventing reading an option for whatever reason which seems to best match your case as it occurs randomly

I'll talk to Sharkie and we'll have to see if your issue is common enough to include a fix for this flaw in Night Config Fixes, so that the config found in defaultconfigs is used for such corrections instead of the built-in values.

commented

Also the .bak files generating is part of the file watcher's behavior when correcting a config: the old broken config is copied to the .bak file and then corrected.

And finally just a tip for editing configs: Such problems sometimes occur when the config is edited while the server/game is running. Make sure everything is closed when editing the config files. If you really want to edit configs while in-game, look at installing the Configured mod to do so, it shouldn't cause such issues.

commented

Hey there, thanks for the report. This is a bit to unpack, so here we go:

This essentially comes from a design flaw/oversight within Forge's config system related to configs in defaultconfigs.

The problem is configs in the defaultconfigs directory are only used when the config is first created (meaning the file is completely absent in .minecaft/config or in .minecraft/saves/WORLD_NAME/serverconfig). In that case the default file from defaultconfigs is simply copied over.

In your case though, the config watcher finds some issues with your already existing file in .minecaft/config which is indicated by this line (note that this part is from Forge, I only had to copy that piece of code to get Night Config Fixes working):

[01Mar2023 14:32:07.355] [Thread-0/WARN] [fuzs.nightconfigfixes.config.CheckedConfigFileTypeHandler/CONFIG]: Configuration file /home/mch/multicraft/servers/server240349/config/backpacked-common.toml is not correct. Correcting

In that case, and that's the reason for the behavior you are seeing, Forge does NOT load the config from defaultconfigs and restores the value from there. Instead the default value defined in code by the mod the config is from is used. The reason for this is that not the whole config is restored, but only the problematic options (might still be the whole file, but must not).

There are a lot of reasons why such a correction can happen, like:

  • An invalid value for an option which is reset
  • Missing options which are added
  • Options that no longer exist which are removed
  • Or even just something being weird with the file and preventing reading an option for whatever reason which seems to best match your case as it occurs randomly

I'll talk to Sharkie and we'll have to see if your issue is common enough to include a fix for this flaw in Night Config Fixes, so that the config found in defaultconfigs is used for such corrections instead of the built-in values.

Thank for your explanation.
But why are config files corrected that where not changed by me?
And also files where i only change 1 number like, 1 to 3.

I know what the mod should do but in my opinion there has to be something wrong in the detection of an "error" in the file.

Every file was changed from me when the server was stopped and like i mentioned even files are corrected that arent changed by me and are default of the modpack.

commented

The error doesn't have to be neccessarily come from you. I mean although solving a different issue that's basically why Night Config Fixes exists. Config files can just randomly get 'corrupted'.

A likely cause for this is that Forge/Night Config (Forge's underlying config library) seems to also rewrite the config file once it's been read (which is unneccessary since the exact same contents that have just been read are simply written again). This is where issues like this can happen.

commented

What would possibly help me to fix this behavior in Forge is if you could e.g. for the backpacked-common.toml file provide the file itself and all .bak versions of it so I can investigate and test how one would go about making a workaround for this issue.

Feel free to join our Discord server and find me there in #fuzs-projects for sending the files.
https://lunapixel.studio/discord

commented

Okay. I just deactivated the mod for now.
For me this is something that i dont have to know.
I just wanted to changed some integers in a config file. (:

Also i generally think this is more a topic for modpack creators.

hm i'm sorry but i deleted the .bak files already to have a clean config folder now. :I

But they where really all the same just 1 integer was different.

Like in the backpack file "backpackInventorySize = 1" instead of "backpackInventorySize = 3".

I compared the files in vs code because i dont trust my eyes. ^^

commented

I could only send you the files i have now that are working correctly and where detected as incorrect.

commented

Those won't help me, I need the .bak files, but thanks anyways.

commented

Yeah sorry i invested plenty of hours the last days to find this. I'm just happy right now that the files arent changed anymore...

commented

Unfortunately, even with the new patch, the same thing happens.

[fuzs.nightconfigfixes.config.CheckedConfigFileTypeHandler/CONFIG]: Loaded default config values from file at path /home/mch/multicraft/servers/server240349/defaultconfigs/backpacked-common.toml

correctConfigValuesFromDefaultConfig = true

But now i can provide the files:

backpackednightconfig.zip

The Log states it load from /deafultconfig/ but you can see in the file in /config/ that there is again 1 instead of 3 so it again restores the mod defaults.

commented

Please uplaod your full latest.log.

commented

2023-03-08-7.log.gz

This is the Log-File from Yesterday to the time when i noticed that the backpack is small again.

commented

Found the cause, fixed in v4.0.6.

commented

Danke dir ๐Ÿ’ฏ