You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Saving to a read-only file or unwritable folder crashes Schema.Editor instead of showing the save-failed popup #255
SchemaFile.TrySave (Schema.Editor/SchemaFile.cs, the try around Directory.CreateDirectory / File.WriteAllText) catches only JsonException and IOException. Both of those calls throw UnauthorizedAccessException when the target file is read-only or the directory isn't writable, and UnauthorizedAccessException is not an IOException, so it escapes.
SchemaFile.Load in the same file already catches UnauthorizedAccessException, so the load and save paths handle the same failure differently.
There is nothing above the save path to catch it. SaveToCurrentPath (Schema.Editor/SchemaEditor.Files.cs) expects TrySave to return false and then shows the "Failed to save schema to '...'" popup. That popup is never reached.
Failure scenario
Open a .schema.json that is read-only, for example a Perforce or other VCS checkout that isn't opened for edit, or a file with attrib +r. Alternatively, use Save As into a directory you can't write to.
Make edits.
Press Ctrl+S, choose File > Save, or click "Save" on the unsaved-changes prompt that appears when you close the editor.
UnauthorizedAccessException escapes the ImGui frame callback and the editor terminates. The edits the user was trying to save are lost.
Secondary problem in the same flow
SaveAs assigns CurrentSchemaPath = filePath before it attempts the save. Even once the crash is fixed, a Save As that fails leaves the document pointing at the path that failed. The window title shows that path, and the next Ctrl+S writes there instead of to the previous good path.
Suggested fix
Catch UnauthorizedAccessException in TrySave. Ideally, return the failure reason the way Load does (Message = ...), so the popup can say why the save failed (read-only, access denied) instead of giving a generic message.
In SaveAs, assign CurrentSchemaPath only after the save succeeds, or restore the previous path when it fails.
Add a SchemaFileTests case that saves over a read-only file and asserts that TrySave returns false instead of throwing.
Related but distinct: #243 covers the same exception class in GenerateToDisk / kschema, not the editor's document save.
Priority: High. Saving to a read-only file, which is common in Perforce and other VCS workflows, crashes Schema.Editor, and the user loses the edits they were trying to save. The fix is small: catch UnauthorizedAccessException in TrySave, which Load already does.
Area / suggested owner:Schema.Editor/SchemaFile.cs (TrySave) and SchemaEditor.Files.cs (SaveAs path handling).
Activity
matt-edmondson commentedon Oct 6, 2026
Triage
UnauthorizedAccessExceptioninTrySave, whichLoadalready does.Schema.Editor/SchemaFile.cs(TrySave) andSchemaEditor.Files.cs(SaveAspath handling).GenerateToDisk/ kschema). No open PR covers it. Open PR Bump ktsu.AppDataStorage and 26 others #254 is only a dependency bump.Generated by Claude Code
Report a save the user may not write instead of crashing