Skip to content

validate: take the report's filename from core's validate() return value #1237

Description

@rbeezer

Core's validate() now returns the report's filename, as of PreTeXtBook/pretext#3216 (merged 2026-09-15). It returns None when no report was written, which happens when method="server" and the validation server cannot be reached or reports an error. The parameters are unchanged, so nothing breaks today: Target.validate_source() calls it with keyword arguments and ignores the result.

Taking the filename from the return value would let two things come out of pretext/project/__init__.py:

  • A second copy of core's naming rule. Line 921 rebuilds <source stem>-validation.txt. If core ever names the report differently, the CLI finds no file and reports "Validation could not be performed".
  • An existence test standing in for "did core write a report?" (lines 922-924). Nothing removes an earlier report from logs/ first, so when core writes nothing, the report from a previous run is read as this run's result, and pretext validate reports that run's message counts.

Roughly:

        try:
            report_name = core.validate(
                ...
            )
        except OSError as e:
            log.debug(f"Validation could not run: {e}")
            return None
        finally:
            ...
        if report_name is None:
            # core writes no report when it cannot use the validation server
            return None
        report = Path(report_name)

What comes back is the path as a string: out_file exactly as passed, or else dest_dir joined with <source stem>-validation.txt. The CLI passes an absolute dest_dir, so it would receive an absolute path. A missing jing still raises OSError, which validate_source() already catches.

The earlier notes on core's validation rework are in #1189.

Claude Opus 5, acting as a coding assistant for Rob Beezer

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions