You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Resolve preset templates without PyYAML on the execution host - #5531
Preset template resolution can fail when Specify is installed in an isolated environment and the Python interpreter on the agent's machine lacks PyYAML. The CLI now records validated template fields in the installed preset registry. Generated Bash, PowerShell, and Python resolvers read those fields with Python's standard library and direct users to refresh the project when the data is missing or stale.
Preset updates and explicit project refreshes regenerate the data. Existing generated scripts keep their current behavior until refreshed.
The affected macOS suite passed 1,296 tests after merging current main, with 52 platform or fixture skips. It included the new Unicode preset-path regression and upstream legacy UTF-8 controls.
Tested a relocated sample project with an installed preset and an isolated interpreter that cannot import PyYAML. Covered missing and stale data, upgrade recovery, update, and removal.
The same regression failed on upstream main with PyYAML is required to resolve preset template composition. Native Windows PowerShell 5.1 verification passed on 240a667, including the batch-launcher variant and Unicode preset paths. The run finished with 169 passes and 101 platform/fixture skips.
AI Disclosure
I did not use AI assistance for this contribution
I did use AI assistance
AI disclosure: OpenAI Codex (GPT-6.2 Sol, gpt-6.2-sol, xhigh reasoning, autonomous mode) investigated the issue, wrote the implementation, tests, and documentation, ran local verification, and drafted this pull request on behalf of @XSY-28. There was no human line-by-line review before submission.
Review follow-up
Commit c978d1d checks Python 3.11+ before accepting an override or fallback. The Bash extension registry reader can use the same PyYAML-free interpreter. Refresh validates all installed manifests and registry data before copying shared scripts. Generated projects require the projection for manifest-bearing presets after refresh, and projects with earlier generated scripts can still use the established YAML path until they upgrade.
The new regressions cover loss of both projection fields, missing or corrupted registry data, malformed YAML, mismatched preset identity, and a failed refresh leaving existing script bytes untouched. The FileHelper check passed on the locally constructed merge tree against the current upstream base used for verification.
The affected local suite passed 2,019 tests with 133 skips. Windows PowerShell 5.1.26100.33822 passed 266 tests with 121 fixture or platform skips on the exact review commit. Native Windows verification
OpenAI Codex (GPT-6.2 Sol, xhigh, autonomous) handled this review round on behalf of @XSY-28.
Second review follow-up
Commit 6695625 uses UTF-8 for the private Bash resolver pipe and reports when a project needs a compatible Python interpreter to honor its registry. The Python entry point returns its normal resolution error when a file cannot be accessed. Preset refresh honors permitted links inside the project and keeps the existing journal and atomic registry-write safeguards.
All four reported cases were reproduced before these changes. The affected local suite passed 2,024 tests with 133 skips, and the FileHelper boundary check passed on the locally constructed upstream merge tree. The exact commit passed 270 tests with 122 skips on Windows PowerShell 5.1.26100.33822. Native Windows verification
OpenAI Codex (GPT-6.2 Sol, xhigh, autonomous) handled this review round on behalf of @XSY-28.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved interpreter-selection and registry/projection recovery defects can break preset composition, leave template resolution unrepaired, or silently restore the PyYAML dependency.
This PR moves preset-template validation into Specify CLI and stores validated fields in the installed registry, allowing refreshed project scripts to resolve templates without PyYAML on the execution host.
Changes:
Generate template projections during preset installation and explicit refresh.
Update all three resolver variants to read projections and detect stale data.
Document execution-host requirements and add relocated, PyYAML-free regression coverage.
AI-generated review for the requester by GitHub Copilot (model unknown, autonomous); analysis and summary are AI-generated.
File
Description
tests/test_preset_template_execution_host.py
Exercises resolution, refresh, update, and removal on an isolated execution host.
tests/test_check_prerequisites_python_parity.py
Reuses the shared script-installation helper.
src/specify_cli/presets/_registry.py
Stores and refreshes validated template projections.
src/specify_cli/presets/_manifest.py
Hashes the exact manifest bytes parsed.
src/specify_cli/presets/_manager.py
Records projection metadata during installation.
src/specify_cli/markdown_sections.py
Adds shared projection validation and template lookup.
src/specify_cli/__init__.py
Refreshes preset projections with shared infrastructure.
scripts/python/common.py
Resolves templates using registry metadata.
scripts/powershell/common.ps1
Adds projection-based resolution and stdlib interpreter selection.
scripts/bash/common.sh
Adds projection-based resolution and stdlib interpreter selection.
docs/upgrade.md
Explains projection refresh during integration upgrades.
docs/presets/api.md
Documents runtime requirements and recovery guidance.
docs/installation.md
Clarifies Python requirements on the execution host.
…ut as UTF-8 (github#5504)
In src/specify_cli/_version.py, Tier-3 install-method detection (uv tool list
and pipx list --json) and post-upgrade verification (specify --version) called
subprocess.run(..., capture_output=True, text=True) without an explicit
encoding:
- On Windows (cp1252), UTF-8 paths or metadata containing cp1252-undefined
bytes (such as 0x90 or 0x9D) caused subprocess._readerthread to fail with an
unhandled background-thread UnicodeDecodeError and leave result.stdout as
None, silently misclassifying uv tool and pipx installations as unsupported
and failing _verify_upgrade().
- Under narrow POSIX locales (LC_ALL=C), non-ASCII bytes in specify --version
output raised an unhandled UnicodeDecodeError from _verify_upgrade() past
except (TimeoutExpired, OSError).
Pass encoding="utf-8", errors="replace" to all three captured subprocess calls.
Fixesgithub#5503
Assisted-by: OpenCode (model: Gemini 4 Carbon, autonomous)
…g Python helpers (github#5506)
Following github#5475, auto_commit.py, initialize_repo.py, and git_common.py still
invoked git with capture_output=True, text=True and no explicit encoding, and
printed diagnostics directly to sys.stderr without a narrow-pipe fallback:
- In auto_commit.py, git ls-files --others --exclude-standard with
core.quotepath=false emitted raw UTF-8 paths whose cp1252-undefined bytes
(such as 0x90) left stdout as None and crashed .stdout.strip() with
AttributeError.
- In auto_commit.py and initialize_repo.py, git failures emitting UTF-8 bytes
undefined in cp1252 left result.stdout or result.stderr as None and crashed
(result.stdout + result.stderr) with TypeError.
- In auto_commit.py, initialize_repo.py, and git_common.py, writing non-ASCII
diagnostics or branch names to narrow stderr pipes raised UnicodeEncodeError.
Decode git subprocess streams as UTF-8 with replacement, guard nullable streams,
write stderr lines with backslashreplace fallback, and bump the git extension
to 1.0.9.
Fixesgithub#5505
Assisted-by: OpenCode (model: Gemini 4 Carbon, autonomous)
…tics in Resolve-TemplateContent (github#5502)
* fix(powershell): preserve non-ASCII preset paths and manifest diagnostics in Resolve-TemplateContent
In scripts/powershell/common.ps1, Resolve-TemplateContent Base64-encoded
section selectors from the Python preset.yml probe but printed file_value raw
and redirected stderr under the caller's $ErrorActionPreference = 'Stop':
- Non-ASCII file paths encodable in cp1252 (e.g. templates/cafe with accent)
were decoded by Windows PowerShell 5.1 under OEM cp437, silently missing the
preset layer and falling through to lower layers.
- Non-ASCII file paths outside cp1252 (or under ASCII locales) raised
UnicodeEncodeError inside the probe and failed as manifest_invalid.
- Missing PyYAML (exit 2) and malformed preset.yml (exit 3) triggered a
terminating NativeCommandError on stderr redirection before reaching the
$LASTEXITCODE handlers.
Base64-encode file_value alongside selector, relax $ErrorActionPreference
around the probe (matching replace-section), and write probe error details
directly to the temp file as UTF-8.
Fixesgithub#5501
Assisted-by: OpenCode (model: Gemini 4 Carbon, autonomous)
* test(powershell): restrict only stdio pipe encoding on POSIX in github#5502
Keep UTF-8 filesystem encoding intact on POSIX runners by setting
PYTHONIOENCODING=ascii instead of LC_ALL=C / LANG=C / PYTHONCOERCECLOCALE=0,
so candidate.is_file() resolves Unicode preset paths while the Python probe
pipe remains ASCII-restricted.
Assisted-by: OpenCode (model: Gemini 4 Carbon, autonomous)
`extension add` printed the catalog entry's name with ext_info['name'],
so an entry without one exited with KeyError: 'name' before the
download started. github#5308 made search and info fall back to the ID for
the same entries; add now does too, as the preset twin already does.
Assisted-by: Claude Code (model: Claude Opus 5.5, autonomous)
preset add printed manifest.name and the catalog entry name straight
into Rich markup, so a name like "Lean Kit [beta]" lost its bracketed
part and "Lean [/] Kit" raised MarkupError after the preset was
already installed. github#3826 escaped the same fields in preset list and
info; add now matches, as extension add already does.
Assisted-by: Claude Code (model: Claude Opus 5.5, autonomous)
Keep direct helper invocation for Windows batch launchers and upstream's Base64 path transport and UTF-8 diagnostics.
Assisted-by: OpenAI Codex (model: GPT-6.2 Sol, autonomous)
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Non-ASCII template filenames fail under ASCII stdout, and missing or invalid registries cause upgrade refresh to silently skip installed presets, leaving template resolution broken.
The new projection path still writes the manifest filename directly to Python's stdout, whose encoding is inherited from the execution host. With a valid projection referencing préface-功能.md and PYTHONIOENCODING=ascii, this invocation fails with UnicodeEncodeError and returns no template; the same fixture resolves successfully with UTF-8, without PyYAML. Force UTF-8 for this subprocess, or use the ASCII-safe filename transport used by the PowerShell helper.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved Unicode filename handling, uncaught filesystem errors, and skipped legacy preset refreshes can break template resolution or report a successful refresh without restoring functionality.
Probe the minimum Python version before accepting a runtime. Validate registry recovery before copying scripts and keep configuration I/O inside FileHelper.
Assisted-by: OpenAI Codex (model: GPT-6.2 Sol, autonomous)
Use UTF-8 for Bash's private manifest pipe, require an interpreter when registry order matters, and report Python filesystem errors. Honor scoped preset input links without changing the journaled registry write boundary.
Assisted-by: OpenAI Codex (model: GPT-6.2 Sol, autonomous)
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate a manifest-symlink handling concern that can silently ignore declared configuration and mislabel valid presets as corrupted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
triage-must-haveVerdict: high-value, important work for Spec Kit — do first
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Preset template resolution can fail when Specify is installed in an isolated environment and the Python interpreter on the agent's machine lacks PyYAML. The CLI now records validated template fields in the installed preset registry. Generated Bash, PowerShell, and Python resolvers read those fields with Python's standard library and direct users to refresh the project when the data is missing or stale.
Preset updates and explicit project refreshes regenerate the data. Existing generated scripts keep their current behavior until refreshed.
Related to #4884, phase 1.
Testing
.venv/bin/specify --helpThe same regression failed on upstream main with
PyYAML is required to resolve preset template composition. Native Windows PowerShell 5.1 verification passed on240a667, including the batch-launcher variant and Unicode preset paths. The run finished with 169 passes and 101 platform/fixture skips.AI Disclosure
AI disclosure: OpenAI Codex (GPT-6.2 Sol,
gpt-6.2-sol, xhigh reasoning, autonomous mode) investigated the issue, wrote the implementation, tests, and documentation, ran local verification, and drafted this pull request on behalf of @XSY-28. There was no human line-by-line review before submission.Review follow-up
Commit
c978d1dchecks Python 3.11+ before accepting an override or fallback. The Bash extension registry reader can use the same PyYAML-free interpreter. Refresh validates all installed manifests and registry data before copying shared scripts. Generated projects require the projection for manifest-bearing presets after refresh, and projects with earlier generated scripts can still use the established YAML path until they upgrade.The new regressions cover loss of both projection fields, missing or corrupted registry data, malformed YAML, mismatched preset identity, and a failed refresh leaving existing script bytes untouched. The FileHelper check passed on the locally constructed merge tree against the current upstream base used for verification.
The affected local suite passed 2,019 tests with 133 skips. Windows PowerShell 5.1.26100.33822 passed 266 tests with 121 fixture or platform skips on the exact review commit. Native Windows verification
OpenAI Codex (GPT-6.2 Sol, xhigh, autonomous) handled this review round on behalf of @XSY-28.
Second review follow-up
Commit
6695625uses UTF-8 for the private Bash resolver pipe and reports when a project needs a compatible Python interpreter to honor its registry. The Python entry point returns its normal resolution error when a file cannot be accessed. Preset refresh honors permitted links inside the project and keeps the existing journal and atomic registry-write safeguards.All four reported cases were reproduced before these changes. The affected local suite passed 2,024 tests with 133 skips, and the FileHelper boundary check passed on the locally constructed upstream merge tree. The exact commit passed 270 tests with 122 skips on Windows PowerShell 5.1.26100.33822. Native Windows verification
OpenAI Codex (GPT-6.2 Sol, xhigh, autonomous) handled this review round on behalf of @XSY-28.