Portality

Portality

14M Downloads

Mod crashes game when invalid JSON returned during contributor data loading

tehbeard opened this issue ยท 3 comments

commented

Today during Github's downtime, modpacks with Portality in were unable to be started, due to a invalid JSON error caused by this line:

giver.addReward(new Reward(new ResourceLocation(Portality.MOD_ID, "aura"), new URL("https://raw.githubusercontent.com/Buuz135/Industrial-Foregoing/master/contributors.json"), () -> dist -> {

image

Some additional checks to prevent JSON errors crashing the game would've prevented this.

Error log from a discord channel.

---- Minecraft Crash Report ----
// This doesn't make any sense!

Time: 11/27/21 4:43 PM
Description: Mod loading error has occurred

java.lang.Exception: Mod Loading has failed
	at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:85) [?:?] {re:classloading}
	at net.minecraftforge.fml.client.ClientModLoader.completeModLoading(ClientModLoader.java:188) [?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.lambda$null$1(Minecraft.java:508) [?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft$$Lambda$12568/1216745400.run(Unknown Source) [?:?] {}
	at net.minecraft.util.Util.func_215077_a(Util.java:320) [?:?] {re:mixin,re:classloading,pl:mixin:APP:ftbchunks-common.mixins.json:UtilMixin,pl:mixin:A}
	at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:504) [?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft$$Lambda$12302/2007058705.accept(Unknown Source) [?:?] {}
	at net.minecraft.client.gui.ResourceLoadProgressGui.func_230430_a_(ResourceLoadProgressGui.java:113) [?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:kubejs-common.mixins.json:ResourceLoadProgressGuiMixin,pl:mixin:A,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:481) [?:?] {re:mixin,pl:accesstransformer:B,xf:fml:fairylights:GameRendererTransformer,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:fairylights:GameRendererTransformer,pl:mixin:A,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:976) [?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A}
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {}
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {}
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}
	at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}
	at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.5-36.2.8.jar:36.2] {}
	at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$478/227972178.call(Unknown Source) [forge-1.16.5-36.2.8.jar:36.2] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {re:classloading}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {re:classloading}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:90) ~[gson-2.8.0.jar:?] {}
-- MOD portality --
Details:
	Mod File: portality-1.16.4-3.2.2.jar
	Failure message: Portality (portality) has failed to load correctly
		java.lang.IllegalStateException: Not a JSON Object: null
	Mod Version: 3.2.2
	Mod Issue URL: NOT PROVIDED
	Exception message: java.lang.IllegalStateException: Not a JSON Object: null
Stacktrace:
	at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:90) ~[gson-2.8.0.jar:?] {}
	at com.hrznstudio.titanium.reward.Reward.getPlayers(Reward.java:43) ~[?:3.2.8.5] {re:classloading}
	at com.hrznstudio.titanium.reward.Reward.<init>(Reward.java:35) ~[?:3.2.8.5] {re:classloading}
	at com.buuz135.portality.Portality.<init>(Portality.java:93) ~[?:3.2.2] {re:classloading}
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_51] {}
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_51] {}
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_51] {}
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[?:1.8.0_51] {}
	at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_51] {}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81) ~[?:36.2] {re:classloading}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer$$Lambda$3136/294886047.run(Unknown Source) ~[?:?] {}
	at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.ModContainer$$Lambda$3846/1204820315.run(Unknown Source) ~[?:?] {}
	at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1618) ~[?:1.8.0_51] {}
	at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1610) ~[?:1.8.0_51] {}
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_51] {}
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_51] {}
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[?:1.8.0_51] {re:computing_frames}
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_51] {}


-- System Details --
Details:
	Minecraft Version: 1.16.5
	Minecraft Version ID: 1.16.5
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_51, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 1059341128 bytes (1010 MB) / 3442999296 bytes (3283 MB) up to 7635730432 bytes (7282 MB)
	CPUs: 12
	JVM Flags: 5 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx8192m -Xms256m -XX:PermSize=256m
	ModLauncher: 8.0.9+86+master.3cf110c
	ModLauncher launch target: fmlclient
	ModLauncher naming: srg
	ModLauncher services: 
		/mixin-0.8.4.jar mixin PLUGINSERVICE 
		/eventbus-4.0.0.jar eventbus PLUGINSERVICE 
		/forge-1.16.5-36.2.8.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.16.5-36.2.8.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE 
		/forge-1.16.5-36.2.8.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.16.5-36.2.8.jar runtimedistcleaner PLUGINSERVICE 
		/mixin-0.8.4.jar mixin TRANSFORMATIONSERVICE 
		/forge-1.16.5-36.2.8.jar fml TRANSFORMATIONSERVICE 
	FML: 36.2
	Forge: net.minecraftforge:36.2.8
	FML Language Providers: 
		[email protected]
		minecraft@1
		[email protected]
	Mod List: 
		enchantedbookredesign-3.3-1.16.4.jar              |Enchanted Book Redesign       |enchantedbookredesign         |3.3-1.16.4          |CREATE_REG|Manifest: NOSIGNATURE
... (134 lines left)
commented

Just submitted #114 which should fix this particular issue

commented

Just submitted #114 which should fix this particular issue

The error was with JSON parsing as GitHub returned a 500 error page with html contents, not the expected file, does your PR check for this?

commented

Just submitted #114 which should fix this particular issue

The error was with JSON parsing as GitHub returned a 500 error page with html contents, not the expected file, does your PR check for this?

My PR sends a HTTP request and if it receives a 200 response (HTTP Get Success) then it will process the JSON code, otherwise, it continues without a fatal error.