Skip to content

feat: warn on existing symlink encounters - #5469

Open
mnriem wants to merge 3 commits into
github:mainfrom
mnriem:mnriem-spec-kit-initialization-842
Open

mnriem wants to merge 3 commits into
github:mainfrom
mnriem:mnriem-spec-kit-initialization-842

Conversation

@mnriem

@mnriem mnriem commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Description

Introduce the first deprecation step for special symlink handling:

  • Warn when FileHelper or existing Python symlink-specific handling encounters a symlink, including archive and native Windows recognition. Do not scan unrelated project paths.
  • Explain that symlinks are not specifically supported and users are responsible for their outcomes.
  • Preserve existing allow/reject behavior, containment checks, and machine-readable output. JSON errors include the notice in their existing error message.

Update the README, core overview, and FileHelper design documentation to describe the transition. This does not remove existing protections or --allow-symlinks.

Testing

Set up this checkout's .venv and editable install using the local development guide. Run commands from the checkout root.

  • Tested locally with .venv/bin/specify --help (Windows PowerShell: .\.venv\Scripts\specify.exe --help)
  • Ran relevant existing tests with .venv/bin/python -m pytest tests -q (Windows PowerShell: .\.venv\Scripts\python.exe -m pytest tests -q); use affected test paths for focused checks and LC_ALL=en_US.UTF-8 on macOS
  • Tested with a sample project (if applicable)

Automated validation on macOS:

  • .venv/bin/specify --help: passed.
  • COLUMNS=1000 LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest tests/test_symlink_warning.py tests/integrations/test_integration_opencode.py tests/test_shared_infra_gitignore.py tests/test_shared_infra_lock.py tests/test_shared_infra_integrity.py -q --disable-warnings: 113 passed. Includes sample-project CLI initialization/status, strict JSON failures, warning-state isolation, and the newly added upstream OpenCode checks.
  • COLUMNS=1000 LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest -n auto -q --disable-warnings: 17,196 passed, 254 skipped.
  • uvx ruff@0.15.0 check src tests --output-format concise: passed.
  • npx --no-install markdownlint-cli2 README.md docs/overview/core.md design/file-helper.md: passed.
  • git diff --check: passed.

Native Windows execution was not run on this macOS host; the focused tests model native symlink/reparse-point classification.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: GitHub Copilot using GPT-6.1 Sol (gpt-6.1-sol) in agent/autonomous mode; reasoning effort was not specified. Used for implementation, automated tests, documentation, and PR preparation.

mnriem and others added 2 commits November 17, 2026 15:53
Introduce a shared visible symlink deprecation notice at existing Python recognition sites and document unsupported symlink usage and user responsibility. Preserve current filesystem policy and structured JSON error contracts.

Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Connect the upstream ignore-file symlink checks to the shared deprecation notice while preserving skip behavior. Add positive and negative regression cases for root ignore files, nested ignore files and the project marker directory.

Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Symlink-policy notices are lost or omitted in workflow errors, artifact/MCP responses, and POSIX cache checks, while the documentation leaves their applicability to generated development symlinks unclear.

5 open issues
What changed in this PR

Introduces encounter-based symlink deprecation warnings across Specify CLI’s existing filesystem checks, beginning the transition away from special symlink handling without removing current protections or --allow-symlinks.

Changes:

  • Adds shared warning helpers for existing path, metadata, archive, and native Windows checks.
  • Defers notices during JSON commands and folds them into selected error renderers.
  • Adds behavioral coverage and documents the transition policy.

AI-assisted review by GitHub Copilot for the requester; model/settings unavailable; autonomous analysis and fix suggestions.

File Description
tests/​test_symlink_warning.py Tests notices, policy preservation, and JSON handling.
src/​specify_cli/​workflows/​step/​command_add.py Warns on linked development sources.
src/​specify_cli/​workflows/​overlay/​operations.py Adds notices to overlay path checks.
src/​specify_cli/​workflows/​overlay/​layer_sources.py Warns during overlay source validation.
src/​specify_cli/​workflows/​function/​loader.py Warns on linked function packages.
src/​specify_cli/​workflows/​function/​installer.py Adds notices to function ownership checks.
src/​specify_cli/​workflows/​function/​command_add.py Warns on linked development directories.
src/​specify_cli/​workflows/​command_remove.py Warns before rejecting linked workflows.
src/​specify_cli/​workflows/​catalog/​_domain.py Adds notices to registry path checks.
src/​specify_cli/​workflows/​_storage.py Warns on linked storage boundaries.
src/​specify_cli/​workflows/​_package_registry.py Adds notices to package registry checks.
src/​specify_cli/​workflows/​_package_install.py Warns during package validation and copying.
src/​specify_cli/​workflows/​_commands.py Adds notices to workflow path checks.
src/​specify_cli/​workflows/​_command_run_ownership.py Warns during linked-path ownership resolution.
src/​specify_cli/​workflows/​_command_resume_state.py Warns on linked resume-path components.
src/​specify_cli/​workflows/​__init__.py Warns while filtering linked custom steps.
src/​specify_cli/​symlink_warning.py Defines shared notices and deferred-warning state.
src/​specify_cli/​shared_infra.py Adds notices to shared infrastructure checks.
src/​specify_cli/​presets/​_manager_skills.py Warns on linked skill validation roots.
src/​specify_cli/​integrations/​opencode/​__init__.py Warns on existing ignore-layer symlink checks.
src/​specify_cli/​integrations/​manifest.py Adds notices to manifest path handling.
src/​specify_cli/​integrations/​kimi/​__init__.py Warns during legacy skill migration checks.
src/​specify_cli/​integrations/​installer.py Adds notices to package and trust checks.
src/​specify_cli/​integrations/​_lifecycle.py Warns during snapshots and rollback handling.
src/​specify_cli/​integrations/​_helpers.py Warns during manifest resynchronization checks.
src/​specify_cli/​integrations/​_command_scaffold_generation.py Adds notices to scaffold path checks.
src/​specify_cli/​integration_status.py Warns when status detects linked managed files.
src/​specify_cli/​file_helper.py Warns during existing traversal and deletion checks.
src/​specify_cli/​extensions/​_commands.py Adds notices to portable cache checks.
src/​specify_cli/​extensions/​_command_update_transaction.py Warns during update backup and rollback checks.
src/​specify_cli/​extensions/​_command_update_artifacts.py Warns when archiving skips linked entries.
src/​specify_cli/​extensions/​__init__.py Adds notices across extension lifecycle checks.
src/​specify_cli/​events/​__init__.py Warns on linked event configuration paths.
src/​specify_cli/​bundles/​primitives.py Adds notices to registry restoration checks.
src/​specify_cli/​bundles/​packager.py Warns when packaging rejects or skips links.
src/​specify_cli/​bundles/​_commands.py Folds notices into bundle JSON errors.
src/​specify_cli/​artifacts/​_commands.py Folds notices into artifact JSON errors.
src/​specify_cli/​agents.py Adds notices to generated artifact handling.
src/​specify_cli/​_project.py Detects JSON mode and enriches project errors.
src/​specify_cli/​_installed_list_json.py Includes pending notices in list JSON errors.
src/​specify_cli/​_init_options.py Warns on linked initialization options.
src/​specify_cli/​_file_policy.py Adds notices to initialization boundary checks.
src/​specify_cli/​_file_handles.py Warns on native Windows symlink recognition.
src/​specify_cli/​_download_security.py Warns before rejecting archive symlinks.
src/​specify_cli/​__init__.py Scopes deferred notices to CLI invocations.
README.md Introduces and links the deprecation policy.
docs/​overview/​core.md Explains notices and current transition behavior.
design/​file-helper.md Documents warning mechanics and unchanged protections.

Review effort: Max (adaptive)

Comment thread docs/overview/core.md Resolved
Comment on lines +128 to +129
message = symlink_error_message(str(error))
typer.echo(json.dumps({"error": message}, ensure_ascii=False), err=True)
non-zero, so no partial JSON payload leaks even on a late-stage failure.
"""
payload = json.dumps({"error": exc.message}, ensure_ascii=False)
payload = json.dumps({"error": symlink_error_message(exc.message)}, ensure_ascii=False)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've kept MCP response fields and error messages unchanged and documented/tested the existing server-stderr warning channel for artifact list/info. Introducing client-visible warning data would expand this first-step warning/documentation change, so I've taken the intentional adapter-transport alternative you suggested instead. On behalf of @mnriem: GitHub Copilot using GPT-6.1 Sol (gpt-6.1-sol), autonomous mode with reasoning effort unspecified; implementation, tests, documentation, and this reply.

current_path = current_path / part

if current_path.is_symlink():
if path_is_symlink(current_path):
Comment on lines +56 to +57
if pending:
_emit_warning()
Keep lookup and workflow JSON notices in their final error renderer and warn for confirmed POSIX cache symlink refusals without changing refusal behavior. Clarify generated development links and retain MCP server-stderr diagnostics rather than expanding response contracts. Add focused regressions and isolate plain JSON cases from OS path aliases.

Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 22:42
@mnriem

mnriem commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 0d9615d to preserve encounter notices in the final lookup/workflow JSON errors and confirmed POSIX cache refusals. The policy now explicitly includes generated development links without changing link-or-copy behavior. MCP response contracts remain unchanged; the existing server-stderr warning channel is documented and tested instead. On behalf of @mnriem: GitHub Copilot using GPT-6.1 Sol (gpt-6.1-sol), autonomous mode with reasoning effort unspecified; implementation, automated tests, documentation, and this summary.

@mnriem mnriem added the triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review label Nov 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Symlink notices remain missing from workflow JSON failures, BSD EMLINK refusals, and structured MCP errors, leaving reporting inconsistent across failure paths, platforms, and adapters.

5 open issues
2 previously missed issues

In code that hasn't changed since last review

Medium severity Align MCP and CLI symlink warning behavior

src/​specify_cli/​artifacts/​_commands.py:61

The artifact CLI error now includes the notice, while the equivalent MCP error leaves it only on server stderr. design/shared.md (“Typed outcome contract”) requires structured operation warnings, and design/mcp.md (“Design goals: Adapter parity”) requires semantically equivalent warnings and errors. Document and justify a process-diagnostic exception in both designs, or carry a structured notice through both adapters.

AI-generated review by GitHub Copilot (model/settings unavailable; autonomous), for the review requester; review only.

Medium severity Include deferred notices in failed workflow JSON errors

src/​specify_cli/​workflows/​_commands.py:106

A shell step that exits nonzero returns a failed state, so both workflow run --json and workflow resume --json bypass this exception handler. If a symlink was encountered earlier, their JSON error omits the notice and teardown emits a separate stderr warning instead. Consume deferred notices for existing failed/aborted error messages in _emit_workflow_json, and cover returned failures in both commands.

AI-generated review by GitHub Copilot (model/settings unavailable; autonomous), for the review requester; review only.

1 resolved since last review

Review effort: Max (adaptive)


def warn_symlink_refusal(error: OSError, name: str, *, dir_fd: int) -> None:
"""Confirm a failed no-follow open without changing the caller's refusal."""
if error.errno not in (errno.ELOOP, errno.ENOTDIR):

This branch has not been deployed

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

Labels

triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants