Skip to content

Catch exceptions and log when parsing graph models and snapshots#98

Merged
mattwar merged 3 commits into
mainfrom
user/mattwar/GraphSnapshotSchemaFix
May 1, 2026
Merged

Catch exceptions and log when parsing graph models and snapshots#98
mattwar merged 3 commits into
mainfrom
user/mattwar/GraphSnapshotSchemaFix

Conversation

@mattwar

@mattwar mattwar commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Add additional tests for graph models and snapshot schema loading

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves server-side schema loading robustness for graph models by preventing JSON parsing failures (graph model content and snapshot lists) from breaking schema loading, and adds regression tests covering snapshot parsing edge cases.

Changes:

  • Added MSTest coverage for graph model snapshot loading scenarios (no snapshot rows, null snapshot field, malformed snapshot JSON, mixed-good/bad models).
  • Wrapped snapshot JSON deserialization in ServerSchemaSource with try/catch and added logging on failures.
  • Updated GraphModel.TryParse to catch deserialization exceptions and return false instead of propagating.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/ServerTests/Features/ServerSchemaSourceTests.cs New tests validating schema loading resilience when snapshot data is missing/null/malformed.
src/Server/Utilities/GraphModel.cs Makes TryParse resilient to malformed graph model JSON by catching exceptions.
src/Server/Schema/ServerSchemaSource.cs Adds guarded snapshot parsing + logging; changes graph model parsing flow (currently drops models on parse failure).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Server/Schema/ServerSchemaSource.cs Outdated
Comment thread src/Server/Schema/ServerSchemaSource.cs Outdated
Comment thread src/Server/Schema/ServerSchemaSource.cs Outdated
Comment thread src/Server/Utilities/GraphModel.cs
Comment thread src/ServerTests/Features/ServerSchemaSourceTests.cs
Comment thread src/Server/Schema/ServerSchemaSource.cs Outdated
Copilot AI review requested due to automatic review settings May 1, 2026 23:15
@mattwar mattwar merged commit dabfbd1 into main May 1, 2026
7 checks passed
@mattwar mattwar deleted the user/mattwar/GraphSnapshotSchemaFix branch May 1, 2026 23:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +27
catch
{
model = null!;
return false;
}
Comment on lines 16 to +27
public static bool TryParse(string text, out GraphModel model)
{
model = JsonConvert.DeserializeObject<GraphModel>(text);
return model != null;
try
{
model = JsonConvert.DeserializeObject<GraphModel>(text);
return model != null;
}
catch
{
model = null!;
return false;
}
}
catch (JsonException je)
{
_logger?.Log($"ServerSchemaSource: Failed to parse snapshots for graph model '{e.EntityName}': {je.Message}");
Comment on lines +4 to +12
using System.Collections.Immutable;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using Kusto.Data;
using Kusto.Data.Common;
using Kusto.Data.Data;
using Kusto.Language;
using Kusto.Language.Editor;
using Kusto.Vscode;
Comment on lines +239 to +241
public IConnection WithCluster(string clusterName) => this;
public IConnection WithDatabase(string databaseName) => this;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants