{"record":{"id":"36000ff661d72db8","repo":"HMCL-dev/HMCL","slug":"profiles-is-null","errorCode":null,"errorMessage":"profiles is null","messagePattern":"profiles is null","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/terracotta/TerracottaState.java","lineNumber":194,"sourceCode":"        private final int profileIndex;\n\n        @SerializedName(\"profiles\")\n        private final List<TerracottaProfile> profiles;\n\n        HostOK(int port, int index, String state, String code, int profileIndex, List<TerracottaProfile> profiles) {\n            super(port, index, state);\n            this.code = code;\n            this.profileIndex = profileIndex;\n            this.profiles = profiles;\n        }\n\n        @Override\n        public void validate() throws JsonParseException, TolerableValidationException {\n            if (code == null) {\n                throw new JsonParseException(\"code is null\");\n            }\n            if (profiles == null) {\n                throw new JsonParseException(\"profiles is null\");\n            }\n        }\n\n        public String getCode() {\n            return code;\n        }\n\n        public List<TerracottaProfile> getProfiles() {\n            return profiles;\n        }\n\n        @Override\n        public boolean isForkOf(TerracottaState state) {\n            return state instanceof HostOK hostOK && this.index - hostOK.index <= profileIndex;\n        }\n    }\n\n    public static final class GuestConnecting extends Ready {","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/terracotta/TerracottaState.java#L176-L212","documentation":"Fires in HostOK.validate() when the deserialized Terracotta server response has a null profiles list. It is a structural guard over the config-server payload: a host report without its profiles array fails Gson parsing because the client cannot determine which Terracotta profile the host refers to. The input at fault is a JSON response missing the serialized 'profiles' field.","triggerScenarios":"A terracotta state JSON deserialized without the profiles field — absent key, explicit null, or a truncated/older-format file.","commonSituations":"Hand-edited state files; schema changes between versions; partial writes leaving profiles out.","solutions":["Include a non-null 'profiles' member (at least an empty list) in the state JSON","Regenerate the state file via the terracotta flow","Restore a known-good backup of the state file","Catch JsonParseException and re-create the state with defaults"],"exampleFix":"// before\n{\"code\":\"AUTH-CODE\"}\n// after\n{\"code\":\"AUTH-CODE\",\"profiles\":[]}","handlingStrategy":"validation","validationCode":"if (parsedState.get(\"profiles\") == null || parsedState.get(\"profiles\").isJsonNull()) { throw new IllegalArgumentException(\"state.profiles required\"); }","typeGuard":"static boolean hasProfiles(JsonObject o) { return o.has(\"profiles\") && !o.get(\"profiles\").isJsonNull(); }","tryCatchPattern":"try { state.validate(); } catch (JsonParseException e) { /* restore backup or rebuild state */ }","preventionTips":["Serialize profiles even when empty","Keep backups of terracotta state files","Schema-check state JSON before loading"],"tags":["json","validation","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}