Add validation warnings to critical imports

This commit is contained in:
2026-03-14 02:11:30 +01:00
parent 6870aa2aef
commit 216cfd3433
4 changed files with 16 additions and 0 deletions

View File

@@ -383,6 +383,7 @@ This includes:
- overall validity - overall validity
- validation errors - validation errors
- validation warnings
- row count - row count
- cell count - cell count
@@ -490,6 +491,12 @@ If validation fails:
- SQLite load is aborted - SQLite load is aborted
- the command returns an error - the command returns an error
If validation succeeds with warnings:
- artifacts still record the warnings
- SQLite load continues
- the CLI prints each warning before reporting the successful load
This design is deliberate. It is safer to reject ambiguous extraction than to load a nearly-correct but wrong lookup table. This design is deliberate. It is safer to reject ambiguous extraction than to load a nearly-correct but wrong lookup table.
## Database Load Behavior ## Database Load Behavior

View File

@@ -53,6 +53,11 @@ public sealed class CriticalImportCommandRunner
$"Validation failed for '{entry.Slug}'. See {artifactPaths.ValidationReportPath} for details."); $"Validation failed for '{entry.Slug}'. See {artifactPaths.ValidationReportPath} for details.");
} }
foreach (var warning in parseResult.ValidationReport.Warnings)
{
Console.WriteLine($"Warning: {warning}");
}
var loader = new CriticalImportLoader(ResolveDatabasePath(options.DatabasePath)); var loader = new CriticalImportLoader(ResolveDatabasePath(options.DatabasePath));
var result = await loader.LoadAsync(parseResult.Table); var result = await loader.LoadAsync(parseResult.Table);

View File

@@ -3,11 +3,13 @@ namespace RolemasterDb.ImportTool.Parsing;
public sealed class ImportValidationReport( public sealed class ImportValidationReport(
bool isValid, bool isValid,
IReadOnlyList<string> errors, IReadOnlyList<string> errors,
IReadOnlyList<string> warnings,
int rowCount, int rowCount,
int cellCount) int cellCount)
{ {
public bool IsValid { get; } = isValid; public bool IsValid { get; } = isValid;
public IReadOnlyList<string> Errors { get; } = errors; public IReadOnlyList<string> Errors { get; } = errors;
public IReadOnlyList<string> Warnings { get; } = warnings;
public int RowCount { get; } = rowCount; public int RowCount { get; } = rowCount;
public int CellCount { get; } = cellCount; public int CellCount { get; } = cellCount;
} }

View File

@@ -19,6 +19,7 @@ public sealed class StandardCriticalTableParser
var fragments = LoadFragments(xmlContent); var fragments = LoadFragments(xmlContent);
var headerFragments = FindHeaderFragments(fragments); var headerFragments = FindHeaderFragments(fragments);
var validationErrors = new List<string>(); var validationErrors = new List<string>();
var validationWarnings = new List<string>();
var columnCenters = headerFragments var columnCenters = headerFragments
.OrderBy(item => item.Left) .OrderBy(item => item.Left)
@@ -147,6 +148,7 @@ public sealed class StandardCriticalTableParser
var validationReport = new ImportValidationReport( var validationReport = new ImportValidationReport(
validationErrors.Count == 0, validationErrors.Count == 0,
validationErrors, validationErrors,
validationWarnings,
rowAnchors.Count, rowAnchors.Count,
parsedCells.Count); parsedCells.Count);