larksuite / larksuite/oapi-sdk-python

Native test suite fails on Windows because path assertion ignores repr escaping

Open Beginner friendly
#160 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
559
Forks
102
PR merge metrics
No merged PRs in 30d

Description

Affected version and environment

  • lark-oapi 1.7.3
  • Default branch commit: 0b9e6e48b74bb4b34462fc67b7e738b27e73e697
  • Windows 11
  • Python 3.13.13 and 3.14.4

Problem

The repository's native pytest run has one deterministic Windows-only failure:

FAILED lark_oapi/channel/tests/test_upload_error_propagation.py::
test_gather_buffer_missing_local_file_raises_upload_failed

assert nonexistent in str(err)

gather_buffer() intentionally formats the path with {source.path!r}. On Windows, repr() doubles backslashes, so the raw nonexistent string is not a substring of the rendered exception even though the correct path is preserved in err.context["path"] and as the OSError cause.

Reproduction

From a Windows checkout with test extras installed:

python -m pytest -q -p no:cacheprovider

Observed on both tested interpreters:

  • Python 3.13.13: 657 passed, 1 failed
  • Python 3.14.4: 657 passed, 1 failed

The failure is at lark_oapi/channel/tests/test_upload_error_propagation.py:37; the formatting under test is at lark_oapi/channel/outbound/media/uploader.py:163.

A minimal equivalent is:

path = r"C:\tmp\does_not_exist.png"
message = f"could not read local file {path!r}"
assert path in message  # fails because message contains escaped backslashes

Expected behavior

The native test suite should pass on a supported Windows/Python environment while still checking the useful diagnostic contract.

Suggested fix

Make the assertion representation-aware (for example, assert repr(nonexistent) in the message) and retain the existing exact context assertion, which already proves that callers receive the original path value.

I searched open and closed issues, all pull request states, and repository history for the test name, upload failed, Windows path escaping, and does_not_exist.png. I found no existing report or competing fix; the old Windows path issue #1 and PR #2 concern API URL joining, not exception-message representation.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lark_oapi/channel/tests/test_upload_error_propagation.py:37 and compare the assertion with the formatting at lark_oapi/channel/outbound/media/uploader.py:163. Run python -m pytest -q -p no:cacheprovider in a supported Windows environment; done means the native suite passes while the existing context-path assertion remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems, testing-qa
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.