{"record":{"id":"a4c1893ec493e69a","repo":"netchx/netch","slug":"server-not-found","errorCode":null,"errorMessage":"Server not found.","messagePattern":"Server not found\\.","errorType":"exception","errorClass":"MessageException","httpStatus":null,"severity":"warning","filePath":"Netch/Forms/MainForm.cs","lineNumber":944,"sourceCode":"        }\n\n        // Activate Profile\n\n        if (profile == null)\n        {\n            MessageBoxX.Show(i18N.Translate(\"No saved profile here. Save a profile first by Ctrl+Click on the button\"));\n            return;\n        }\n\n        try\n        {\n            ProfileNameText.Text = profile.ProfileName;\n\n            var server = ServerComboBox.Items.Cast<Server>().FirstOrDefault(s => s.Remark.Equals(profile.ServerRemark));\n            var mode = ModeComboBox.Items.Cast<Mode>().FirstOrDefault(m => m.Remark.Any(s => s.Value.Equals(profile.ModeRemark)));\n\n            if (server == null)\n                throw new MessageException(\"Server not found.\");\n\n            if (mode == null)\n                throw new MessageException(\"Mode not found.\");\n\n            // set active server and mode\n            ServerComboBox.SelectedItem = server;\n            ModeComboBox.SelectedItem = mode;\n        }\n        catch (MessageException exception)\n        {\n            MessageBoxX.Show(exception.Message, LogLevel.ERROR);\n            return;\n        }\n\n        await StopAsync();\n        ControlButton.PerformClick();\n    }\n","sourceCodeStart":926,"sourceCodeEnd":962,"githubUrl":"https://github.com/netchx/netch/blob/9d99eb1c5a2acbf2a34f2600f94242601019a300/Netch/Forms/MainForm.cs#L926-L962","documentation":"Thrown by MainForm profile activation when no Server in ServerComboBox has a Remark equal to profile.ServerRemark — i.e. the saved profile references a server that no longer exists (deleted or renamed). The first FirstOrDefault returns null and the guard fires before the mode lookup. It is caught immediately and shown via MessageBoxX (LogLevel.ERROR), so it is a user-facing warning rather than a crash.","triggerScenarios":"A profile was saved against a server that has since been deleted; the server's Remark was edited after the profile was created; profile import from another machine whose server list differs; empty/migrated server list with old profiles.","commonSituations":"User deleted a server but kept profiles that point at it; renamed a server; copied profiles.xml between machines without copying servers; data drift after a config migration.","solutions":["Re-create or rename a server so its Remark matches profile.ServerRemark.","Edit the profile to point at an existing server (re-save it via Ctrl+Click).","Delete the stale profile if the server is gone for good.","Keep server Remarks stable, or update profiles immediately after renaming a server."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before activating a profile, confirm its referenced server still exists.\nvar exists = ServerComboBox.Items.Cast<Server>().Any(s => s.Remark.Equals(profile.ServerRemark));\nif (!exists)\n{\n    MessageBoxX.Show($\"Profile '{profile.ProfileName}' references a server that no longer exists.\", LogLevel.ERROR);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { /* profile activation block */ }\ncatch (MessageException ex) when (ex.Message == \"Server not found.\" || ex.Message == \"Mode not found.\")\n{\n    // already shown via the surrounding catch(MessageException) -> MessageBoxX; offer to delete the stale profile.\n    OfferDeleteStaleProfile(profile);\n}","preventionTips":["When deleting/renaming a server, also update or delete profiles that reference its Remark.","Treat the Remark as a stable key — avoid renaming servers that have profiles attached.","On startup, validate all profiles against the current server/mode lists and flag orphans.","After importing profiles from another machine, import the matching servers too."],"tags":["profile","config","data-integrity","ui"],"backgroundTag":null,"analyzedSha":"9d99eb1c5a2acbf2a34f2600f94242601019a300","analyzedAt":"2026-08-13T14:12:19.105Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}