Skip to content

feat: implement fail-fast dry-run validation for calculation templates#2

Merged
mitchell-tesch merged 6 commits into
mitchell-tesch:mainfrom
eli-lindner-sj:feature/dry-run-validation
Jun 8, 2026
Merged

feat: implement fail-fast dry-run validation for calculation templates#2
mitchell-tesch merged 6 commits into
mitchell-tesch:mainfrom
eli-lindner-sj:feature/dry-run-validation

Conversation

@eli-lindner-sj

Copy link
Copy Markdown
Contributor

This PR introduces a new TemplateValidator service that performs a "dry-run" validation of the calculation template immediately upon starting a batch job. By verifying structural integrity
before spinning up worker processes, it prevents long-running batches from failing mid-execution due to configuration or template errors.

Key Changes

  • Fail-Fast Template Validation (TemplateValidator):
    ** Intercepts the batch process early to verify that all sheets referenced by InputFields and OutputFields actually exist in the target Excel template.
    ** Provides aggregated, human-readable error messages detailing exactly which sheets or ranges are missing, allowing users to correct their configuration or template immediately.
  • The validator opens the template with FileShare.ReadWrite (non-locking shared access), allowing validation to succeed even if the user currently has the template open in Excel.
  • Extracted and centralized the logic for parsing OpenXML Defined Names (BuildDefinedNamesLookup). This ensures the new validator and the existing execution engine
    (CalculationHeaderWriter) use identical rules to identify valid, writable cell references (e.g., Sheet!$A$1), ignoring complex formulas/offsets.
  • The validator aligns with the existing engine's leniency: while missing data sheets are fatal, missing HeaderInputs are silently ignored, ensuring we do not break workflows relying on generic configs across varying templates.

@mitchell-tesch mitchell-tesch marked this pull request as ready for review June 8, 2026 11:45
@mitchell-tesch mitchell-tesch merged commit 1dc6bd9 into mitchell-tesch:main Jun 8, 2026
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