NRE when attempting PlayerProfile update with name only

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    •  This server is running CraftBukkit version 4542-Spigot-6e369ba-59f1b90 (MC: 1.21.10) (Implementing API version 1.21.10-R0.1-SNAPSHOT)
    • Yes

      Attempting to complete / update a PlayerProfile given only a name results in a NRE internally due to an attempt of creating a GameProfile without a UUID.

      Code

      var profile = Bukkit.createPlayerProfile("blablubbabc");
      profile.update().whenComplete((updatedProfile, e) -> {
          if (e != null) {
              Log.severe("Failed to lookup player profile!", e);
              return;
          }
          
          Log.info("Got updated profile!");
          
          SchedulerUtils.runOnMainThreadOrOmit(plugin, () -> {
              // .. do sth with it
          });
      });

      Error:

      java.util.concurrent.CompletionException: java.lang.NullPointerException: Profile ID must not be null
              at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
              at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
              at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770) ~[?:?]
              at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) ~[?:?]
      Caused by: java.lang.NullPointerException: Profile ID must not be null
              at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]
              at com.mojang.authlib.GameProfile.<init>(GameProfile.java:23) ~[authlib-7.0.61.jar:?]
              at org.bukkit.craftbukkit.v1_21_R6.profile.CraftPlayerProfile.buildGameProfile(CraftPlayerProfile.java:214) ~[spigot-1.21.10-R0.1-SNAPSHOT.jar:4542-Spigot-6e369ba-59f1b90]
              at org.bukkit.craftbukkit.v1_21_R6.profile.CraftPlayerProfile.getUpdatedProfile(CraftPlayerProfile.java:177) ~[spigot-1.21.10-R0.1-SNAPSHOT.jar:4542-Spigot-6e369ba-59f1b90]
              at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
              ... 6 more

      The API documentation makes it seem that this should work. I am not fully sure, but this might have changed / "broken" with one of the previous MC updates (I think to vaguely remember GameProfile becoming more strict in the properties it requires to be considered valid).

      There even is some code to handle a missing / NIL UUID, but it is called right after attempting to create the GameProfile. Maybe this uuid lookup needs to happen one step earlier: Or we need to replace the null UUID with the NIL UUID and the null name with an empty string when creating the GameProfile:
      https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java#180

      Same issue applies to profile completions when the name is missing:

      java.util.concurrent.CompletionException: java.lang.NullPointerException: Profile name must not be null
              at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
              at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320) ~[?:?]
              at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770) ~[?:?]
              at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) ~[?:?]
              at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) ~[?:?]
      Caused by: java.lang.NullPointerException: Profile name must not be null
              at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]
              at com.mojang.authlib.GameProfile.<init>(GameProfile.java:24) ~[authlib-7.0.61.jar:?]
              at org.bukkit.craftbukkit.v1_21_R6.profile.CraftPlayerProfile.buildGameProfile(CraftPlayerProfile.java:214) ~[spigot-1.21.10-R0.1-SNAPSHOT.jar:4542-Spigot-6e369ba-59f1b90]
              at org.bukkit.craftbukkit.v1_21_R6.profile.CraftPlayerProfile.getUpdatedProfile(CraftPlayerProfile.java:177) ~[spigot-1.21.10-R0.1-SNAPSHOT.jar:4542-Spigot-6e369ba-59f1b90]
              at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
              ... 6 more 

            Assignee:
            Unassigned
            Reporter:
            blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: