{"record":{"id":"cbdd1b0fdfe498e7","repo":"BornToBeRoot/NETworkManager","slug":"failed-to-deserialize-json-profile-file","errorCode":null,"errorMessage":"Failed to deserialize JSON profile file.","messagePattern":"Failed to deserialize JSON profile file\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Source/NETworkManager.Profiles/ProfileManager.cs","lineNumber":1029,"sourceCode":"        {\n            var profileFileData = JsonSerializer.Deserialize<ProfileFileData>(jsonString, JsonOptions);\n\n            if (profileFileData != null)\n            {\n                LoadedProfileFileData = profileFileData;\n                return;\n            }\n        }\n        catch (JsonException)\n        {\n            Log.Info(\"Failed to deserialize as ProfileFileData, trying legacy format (direct Groups array)...\");\n        }\n\n        // Fallback: Try to deserialize as legacy format (direct array of GroupInfoSerializable)\n        var groupsSerializable = JsonSerializer.Deserialize<List<GroupInfoSerializable>>(jsonString, JsonOptions);\n\n        if (groupsSerializable == null)\n            throw new InvalidOperationException(\"Failed to deserialize JSON profile file.\");\n\n        // Create ProfileFileData wrapper for legacy format\n        LoadedProfileFileData = new ProfileFileData\n        {\n            GroupsSerializable = groupsSerializable\n        };\n\n        Log.Info(\"Successfully loaded profile file in legacy format. It will be migrated to new format on next save.\");\n    }\n\n    /// <summary>\n    ///     Method to deserialize a list of groups as <see cref=\"GroupInfo\" /> from an XML stream.\n    /// </summary>\n    /// <param name=\"stream\">Stream to deserialize.</param>\n    [Obsolete(\"Legacy XML profile files are no longer used, but the method is kept for migration purposes.\")]\n    private static void DeserializeFromXmlStream(Stream stream)\n    {\n        XmlSerializer xmlSerializer = new(typeof(List<GroupInfoSerializable>));","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/BornToBeRoot/NETworkManager/blob/2780d65469917a296dbc15f206107d72e2d0115c/Source/NETworkManager.Profiles/ProfileManager.cs#L1011-L1047","documentation":"Save (also invoked by RenameProfileFile, EnableEncryption, ChangeMasterPassword, DisableEncryption) failed to deserialize the profile file JSON: either the JSON text did not match the ProfileFileData schema (JsonException) and the legacy-format fallback also failed, or deserialization produced null. The file content is corrupt, truncated, hand-edited, or of an unrecognized schema, so the load step of the save pipeline cannot proceed.","triggerScenarios":"Thrown at Source/NETworkManager.Profiles/ProfileManager.cs:1029 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the profile file with a JSON linter and repair syntax errors (trailing commas, truncated content).","Restore the profile file from an automatic backup or a recent copy.","If the file is unreadable, move it aside and let the application create a fresh profile file, then re-import profiles.","Ensure the file was not saved with a different/older schema or manually edited in a way that breaks deserialization."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2780d65469917a296dbc15f206107d72e2d0115c","analyzedAt":"2026-09-12T17:00:17.986Z","contentChangedAt":"2026-09-12T17:00:17.986Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}