github/spec-kit · error · PresetValidationError

Invalid template {field}: expected a string, got {type(tmpl[

Error message

Invalid template {field}: expected a string, got {type(tmpl[field]).__name__}

What it means

Error "Invalid template {field}: expected a string, got {type(tmpl[field]).__name__}" thrown in github/spec-kit.

Source

Thrown at src/specify_cli/presets/__init__.py:430

        for tmpl in templates:
            if not isinstance(tmpl, dict):
                raise PresetValidationError(
                    "Each template entry in 'provides.templates' must be a mapping"
                )
            if "type" not in tmpl or "name" not in tmpl or "file" not in tmpl:
                raise PresetValidationError(
                    "Template missing 'type', 'name', or 'file'"
                )

            # 'name' feeds re.match and 'file' feeds os.path.normpath below;
            # both raise a bare TypeError on a non-string, which is not a
            # PresetValidationError and so escapes the callers that handle a
            # malformed manifest. The sibling extension manifest already
            # rejects a non-string command 'file' via
            # relative_extension_path_violation().
            for field in ("type", "name", "file"):
                if not isinstance(tmpl[field], str):
                    raise PresetValidationError(
                        f"Invalid template {field}: expected a string, "
                        f"got {type(tmpl[field]).__name__}"
                    )

            if tmpl["type"] not in VALID_PRESET_TEMPLATE_TYPES:
                raise PresetValidationError(
                    f"Invalid template type '{tmpl['type']}': "
                    f"must be one of {sorted(VALID_PRESET_TEMPLATE_TYPES)}"
                )

            # Validate file path safety: must be relative, no parent traversal
            file_path = tmpl["file"]
            normalized = os.path.normpath(file_path)
            if os.path.isabs(normalized) or normalized.startswith(".."):
                raise PresetValidationError(
                    f"Invalid template file path '{file_path}': "
                    "must be a relative path within the preset directory"
                )

View on GitHub (pinned to bf88c9f9a8)

Solutions

  1. Make the template type/name/file value a string.

When it happens

Trigger: Thrown at src/specify_cli/presets/__init__.py:430 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of github/spec-kit@bf88c9f9a8 (2026-08-14). Data as JSON: /api/errors/c08c4df27464feb4. Report an issue: GitHub.