fix(vendor): recover from tapi_yandex_direct 2026.5.29 bump regressions - #488
Conversation
The 2026.5.29 vendor bump (1ee8c2a) rebuilt direct_cli/_vendor via update_vendor.sh's rm -rf + cp -R of the fork, wiping local patches and desyncing the vendor from the tests. That introduced four regressions; CI surfaced only the first because Quality fails on mypy before the test step: 1. timeout stub (mypy): the .pyi for YandexDirectClientExecutor.get/post dropped the `timeout` kwarg auth.py:631 passes, so mypy rejected the call even though tapi2 forwards it to requests at runtime. 2. to_columns IndexError: upstream reverted the short-row guard; report rows with fewer cells than the header crashed. 3. transport hosts: upstream turned DIRECT_API_PRODUCTION_ROOT into a {tld} template (v5 -> .com, v4 -> .ru); test_transport_contract compared against the un-substituted constant. 4. VCR cassettes: the v5 host moved .ru -> .com but all cassettes are .ru, so the host matcher failed and 42 replay tests broke under --record-mode=none. Fixes: - Re-apply #1 and #2 and make them self-healing in patch_vendor_imports.py (_patch_stub_text for the .pyi, _patch_runtime_text for to_columns) so the next vendor bump cannot silently drop them again; both are idempotent. - Add two gates in test_vendor_imports.py (ast check on the shipped stub + idempotency of _patch_stub_text). - Update test_transport_contract.py to the {tld} contract. - Register a TLD-insensitive VCR host matcher in conftest.py so .ru cassettes replay against .com requests and vice versa. Verified: mypy clean, ruff clean, pytest -m "not integration" all green (2035 passed), self-heal restores both patches on a stripped tmp copy and is a no-op on re-run. Closes #487 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@claude review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 2m 29s —— View job Review: vendor bump regression recoveryI reviewed the diff against Verdict: no blocking issues found. The four fixes are correct and the self-heal logic is genuinely idempotent. Details below. What I verified ✅
Non-blocking observations1. Latent fragility: class-scope prefix match (
_STUB_CLASS_RE = re.compile(r"^class YandexDirectClientExecutor[:\(]")
...
if line.startswith("class "):
in_stub_class = bool(_STUB_CLASS_RE.match(line))2. FYI: v5 live host changed This isn't introduced by the fix (it came from the upstream bump), but the practical effect is that production v5 requests now go to 3. Indentation coupling (minor) — Overall this is a careful, well-tested recovery. The self-heal approach is the right call given |
Review follow-up (#488): _patch_stub_text scoped the stub class with line.startswith("class YandexDirectClientExecutor"), which also matches the prefix-sharing class YandexDirectClientExecutorResponse. Harmless today (that Response body has no get/post or :param data:), but a latent fragility if upstream ever reorders classes. Replace the prefix check with a boundary-aware regex ^class YandexDirectClientExecutor[:\(] so only the exact class is treated as in-scope, and add a gate test feeding a prefix-sharing decoy class with the exact executor signature (would fail on the old startswith check). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Спасибо за внимательный разбор. По трём наблюдениям: 1. Class-scope prefix match — исправлено (commit 2. v5 host 3. Indentation coupling — SKIP, по той причине, которую вы сами и назвали: если апстрим переформатирует whitespace и self-heal тихо станет no-op, два поведенческих/AST-гейта ( |
|
@claude review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 1m 50s —— View job Re-review: vendor bump regression recoveryI re-reviewed the full diff against Verdict: no blocking issues. Commit Commit
|
Что и зачем
Vendor bump
1ee8c2a(обновлениеtapi-yandex-directдо 2026.5.29 черезupdate_vendor.sh=rm -rf+cp -Rфорка) затёр локальные правки и рассинхронизировал вендор с тестами. CI показал только первую регрессию — job Quality падает на mypy ещё до шага с тестами.Четыре регрессии и фиксы
.pyi-стаб потерялtimeoutуget/post→ mypy[call-arg]наauth.py:631(runtime ОК — tapi2 форвардит**kwargsвrequests)_patch_stub_textвpatch_vendor_imports.py+ 2 тест-гейтаto_columnsIndexErrorна коротких строках отчёта (апстрим откатил guard)_patch_runtime_text{tld}(v5→.com, v4→.ru)test_transport_contract.pyпереписан под новый контракт.ru≠ запросы.com→ 42 теста падали при--record-mode=noneconftest.py(pytest_recording_configure)Корень —
update_vendor.shзатирает локальные правки при каждом bump. Поэтому #1 и #2 не просто восстановлены, а самовосстанавливаются послеcp -R(идемпотентно), чтобы будущий bump не уронил CI снова.Проверка
mypy .(Python 3.11) →Success: no issues found in 60 source filespytest -m "not integration"→ 2035 passed, 46 skipped, 0 failedruff check .→All checks passed!Остаётся опционально (вне репо)
Внести
timeoutв.pyiфоркаaxisrow/tapi-yandex-directкак страховку от ребейза апстрима — но self-heal делает это необязательным.Closes #487
🤖 Generated with Claude Code