Skip to content

test(tools): add needs_symlinks marker to three symlink tests - #1917

Open
okxint wants to merge 2 commits into
anthropics:mainfrom
okxint:fix/symlink-tests-need-windows-skip
Open

test(tools): add needs_symlinks marker to three symlink tests#1917
okxint wants to merge 2 commits into
anthropics:mainfrom
okxint:fix/symlink-tests-need-windows-skip

Conversation

@okxint

@okxint okxint commented Sep 7, 2026

Copy link
Copy Markdown

Summary

Fixes #1915.

Three tests in test_agent_toolset.py create symlinks without a platform guard and fail on Windows when the user is not elevated and Developer Mode is off:

Test Failure
test_read_through_symlink_escape_is_rejected OSError: [WinError 1314]
test_glob_post_filters_symlink_escape OSError: [WinError 1314]
test_grep_skips_symlinked_files OSError: [WinError 1314]

All three call Path.symlink_to / os.symlink. Windows requires SeCreateSymbolicLinkPrivilege (elevation or Developer Mode) for unprivileged symlink creation.

Changes

Added a needs_symlinks marker at the top of the file (modelled after the existing needs_pydantic_v2 marker) and applied it to the three tests. The marker is @pytest.mark.skipif(sys.platform == "win32", reason="symlink fixtures need a POSIX filesystem").

sys was already imported, so no new imports are needed.

Test plan

  • pytest tests/lib/tools/test_agent_toolset.py -v — all 3 symlink tests pass on macOS/Linux (verified locally: 3 passed)
  • On Windows without elevation: 3 tests skip instead of failing with WinError 1314

okxint and others added 2 commits July 2, 2026 10:28
…bsent

os.environ.get() returns "" for a present-but-empty var, not None. When
the SDK stored an empty string as auth_token, _bearer_auth emitted an
"Authorization: Bearer " header (trailing space, no token). h11 rejects
that value at write time with LocalProtocolError, surfaced to callers as
APIConnectionError.

Apply `or None` to both env reads so an empty string is treated the same
as the variable being unset. Adds regression tests for both Anthropic and
AsyncAnthropic confirming that api_key, auth_token, and auth_headers are
all None / empty when the env vars are set to "".
Three tests in test_agent_toolset.py create symlinks without a
platform guard, so they fail on Windows when the user is not elevated
and Developer Mode is off:

  test_read_through_symlink_escape_is_rejected
  test_glob_post_filters_symlink_escape
  test_grep_skips_symlinked_files

All three raise OSError: [WinError 1314] because os.symlink /
Path.symlink_to need the SeCreateSymbolicLinkPrivilege on Windows.

Add a local needs_symlinks marker (matching the needs_pydantic_v2
pattern already in the file) and apply it to all three tests so they
skip on Windows instead of failing.

Fixes anthropics#1915

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@okxint
okxint requested a review from a team as a code owner September 7, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Three symlink tests in test_agent_toolset.py are missing the needs_symlinks marker

1 participant