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
SchemaSerializer.Load throws ArgumentException on a .schema.json with an absolute outputPath or data source file, crashing kschema and the editor's File > Open #299
outputPath and file are deserialized through the semantic path types. An absolute value such as "outputPath": "/tmp/out" or "file": "C:\\data\\items.json" makes the converter throw ArgumentException.
SchemaSerializer.Load catches only JsonException (Schema/SchemaSerializer.cs:157 and :205). Open PR #297 adds NotSupportedException, but not ArgumentException. So the exception escapes to two callers:
kschema validate / kschema generate: neither SchemaCommandLine.TryLoad (Schema/Cli/SchemaCommandLine.cs:193) nor Schema.Tool/Program.cs catches it. The user gets a stack trace instead of "Could not open ...".
The editor:SchemaFile.Load (Schema.Editor/SchemaFile.cs:62-80) catches only IOException and UnauthorizedAccessException. Opening such a file, including from the recent-files list, throws out of the frame.
docs/schema-format.md says these paths are relative. Still, a hand-written or tool-written file with an absolute path is easy to produce. It should be refused as InvalidJson, not crash the process.
Repro
SchemaSerializer.Load("{\"formatVersion\":1,\"codeGenerators\":[{\"name\":\"G\",\"language\":\"CSharp\",\"outputPath\":\"/tmp/out\"}]}","/tmp/x.schema.json".As<AbsoluteFilePath>());// throws ArgumentException: Cannot convert "/tmp/out" to RelativeDirectoryPath
Suggested fix / acceptance criteria
Load returns SchemaLoadStatus.InvalidJson with a message that names the property and says paths must be relative to the schema file. Either:
catch ArgumentException around the deserialize call, or
give the path properties a converter that reports a JsonException with the JSON path.
Tests for an absolute outputPath and for an absolute data source file:
Load returns InvalidJson;
kschema validate exits 1 with "Could not open".
Optional: state in schema-format.md that absolute paths are refused.
This is related to #242 and #287, which are other load crashes on different inputs. PR #297 does not cover this one.
Priority: Medium. An absolute outputPath or data source file crashes kschema with a stack trace and throws out of the editor's frame on File > Open. The input violates the documented format, but it is easy to produce and should be refused cleanly.
Area / suggested assignee:SchemaSerializer.Load exception handling (or a path converter that raises JsonException). Owner: @matt-edmondson
Activity
matt-edmondson commentedon Oct 19, 2026
Triage
outputPathor data sourcefilecrasheskschemawith a stack trace and throws out of the editor's frame on File > Open. The input violates the documented format, but it is easy to produce and should be refused cleanly.SchemaSerializer.Loadexception handling (or a path converter that raisesJsonException). Owner: @matt-edmondsonArgumentExceptionfrom the editor's input fields). Open PR Move the editor onto ktsu.UndoRedo 3, stop saves and loads from silently losing a schema, and refuse unreadable or unsizable input #297 hardensLoadbut, per the issue, catchesNotSupportedExceptionand notArgumentException. The smallest route is to extend Move the editor onto ktsu.UndoRedo 3, stop saves and loads from silently losing a schema, and refuse unreadable or unsizable input #297 rather than open a separate PR.SchemaLoadStatus.InvalidJsonnaming the property, with tests for both properties viaLoadandkschema validate.Generated by Claude Code
Report an absolute path in a schema as an invalid file instead of cra…
Refuse paths rooted on any system, not only the host's (#299)