Skip to content

Implement message template syntax deprecation and migration #591

@david-waltermire

Description

@david-waltermire

Summary

Implement the deprecation of single-brace { expr } message template syntax in favor of mustache-style {{ expr }} syntax, as specified in metaschema-framework/metaschema#162.

Implementation Areas

1. Message Template Parser

Location: core/src/main/java/gov/nist/secauto/metaschema/core/model/constraint/impl/ (or similar)

2. Deprecation Warning System

  • Track warned files to emit ONE warning per file (avoid log spam)
  • Warning format: WARNING: File '{}' uses deprecated single-brace template syntax. Use '{{ expr }}' instead of '{ expr }'.
  • Consider adding source location (line/column) for the first occurrence
// Example implementation
private static final Set<URI> warnedFiles = ConcurrentHashMap.newKeySet();

private void warnDeprecatedSyntax(URI sourceFile) {
  if (warnedFiles.add(sourceFile)) {
    LOGGER.warn("File '{}' uses deprecated single-brace template syntax. "
        + "Use '{{ expr }}' instead of '{ expr }'.", sourceFile);
  }
}

3. CLI Migration Command

Location: metaschema-cli

Add a new command to migrate constraint files:

# Dry-run showing what would change
metaschema-cli migrate-templates --dry-run constraints.xml

# Apply changes in place
metaschema-cli migrate-templates constraints.xml

# Output to different file
metaschema-cli migrate-templates constraints.xml -o constraints-v2.xml

# Report mode - list files using deprecated syntax
metaschema-cli migrate-templates --report src/

4. Validation Mode

Add CLI flag or configuration option to treat deprecated syntax as an error:

metaschema-cli validate --strict-templates module.xml

This enables CI pipelines to enforce migration.

Dependencies

Acceptance Criteria

  • Parser updated per chosen transition approach
  • Deprecation warnings emitted (one per file)
  • migrate-templates CLI command implemented
  • --dry-run and --report modes working
  • --strict-templates validation flag implemented
  • Unit tests for parser with both syntaxes
  • Integration tests for CLI migration command
  • Documentation updated

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions