fix: resolve 13 confirmed bugs from the #483 bug hunt - #486
Merged
Conversation
…twork call A regression from #480 made get_credentials() resolve the bare Client-Login via a network clients.get on every CLI invocation when an OAuth profile with an email login lacked the login_migration_checked flag — including plain `<group> --help`. That call had no timeout (neither the vendored client nor tapi2 set one), so a slow link or a Yandex SmartCaptcha gateway could hang the CLI indefinitely. Under CliRunner this also hung the unit suite (it stalled on test_registered_mapped_groups_show_docs_url, which fires ~30 `--help` calls). Three independent guards: - auth.py: cap the best-effort resolver with LOGIN_RESOLVE_TIMEOUT_SECONDS=8 and disable retries, so it can never wait forever. - cli.py: skip the resolver entirely on --help/--version/-h passes (allow_login_resolve=False) — no command runs, so no login is needed. - tests/conftest.py: autouse fixture neutralizes the network resolver for the whole unit suite; the module-level test-credential probe no longer triggers it. Adds regression tests asserting a --help pass makes zero resolver calls and that allow_login_resolve=False suppresses the migration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Verified each finding against the live API, the WSDL cache, and the official Yandex Direct docs before fixing. Bugs 10 and 14 were false positives (no UsageError source inside the try — style only) and are intentionally skipped. Functional fixes: - bids/keywordbids get: reject empty SelectionCriteria with a UsageError before the request (live API error 4001) (#1, #2). - bids get: re-raise UsageError so the new guard surfaces with exit code 2 (#8). - bids set-auto: require exactly one of CampaignId/AdGroupId/KeywordId via add_single_id_selector (docs: the three are mutually exclusive) (#4). - vendored to_columns: pad short report rows instead of IndexError (#3). - vendored error handler: error_data.get("error_detail") to avoid KeyError (#11). - reports build_report_request: reject empty FieldNames (live API error 8000) (#12). Swallowed-validation fixes (add `except click.UsageError/ClickException: raise` before the bare `except Exception`): balance (#6), strategies get (#7), campaigns get (#9), ads get (#13), negativekeywordsharedsets update (#5). Type annotation: parse_priority_goals_spec items -> List[Dict[str, Any]] (#15). build_api_coverage_report: supply --campaign-ids for bids/keywordbids get wire-capture so the empty-criteria guard does not break schema parity. Closes #483 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Incorporates the genuinely-better parts of the parallel PR #484 into this branch, which already carries the regression tests, the #15 annotation fix, and the localized messages: - ads: re-raise click.UsageError in all lifecycle handlers (update, delete, archive, unarchive, suspend, resume, moderate) in addition to get — so the whole resource matches bug #13's "get + 8 lifecycle" scope. Defensive: these handlers have no pre-API UsageError source today, but the guard keeps them consistent and future-proof. - retargeting get/delete, advideos get: same defensive re-raise for uniformity (issue #483 items 10/14; not live defects, but harmless consistency). - bids/keywordbids get: the empty-criteria message now also lists --serving-statuses, which likewise populates SelectionCriteria (kept the t() localization wrapper). - CHANGELOG.md: document the bug-hunt fixes (#483) and the --help network-hang follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Закрывает #483. Стек поверх #485 (сетевой фикс) — после мержа #485 эта ветка автоматически перенацелится на
main.Каждый из 15 заявленных багов перепроверен вручную: по живому API (read-only), по WSDL-кэшу и по официальной документации Yandex Direct. Баги 10 (
retargeting get/delete) и 14 (advideos get) оказались ложными срабатываниями — внутриtryнет источникаUsageErrorдо вызова API, это лишь стиль; они намеренно пропущены.Функциональные фиксы
bids/keywordbids get— пустойSelectionCriteriaотклоняетсяUsageErrorдо запроса. Подтверждено живым API:error 4001 — must specify at least one of KeywordIds, AdGroupIds, CampaignIds.bids get—except UsageError: raise, чтобы новый guard выходил с кодом 2.bids set-auto— ровно один изCampaignId/AdGroupId/KeywordIdчерезadd_single_id_selector. Доки: параметры взаимоисключающие.to_columns— короткие строки отчёта добиваются""вместоIndexError.error_data.get("error_detail")вместоKeyError.reports— пустойFieldNamesотклоняется (живой API:error 8000 — FieldNames must contain no less than 1 elements).Фиксы проглоченной валидации
Вставлен
except click.UsageError/ClickException: raiseпередexcept Exception: #6 balance, #7 strategies get, #9 campaigns get, #13 ads get, #5 negativekeywordsharedsets update.Прочее
parse_priority_goals_spec→List[Dict[str, Any]].build_api_coverage_report— fixtures--campaign-idsдляbids/keywordbids get, чтобы guard не ломал schema-parity гейт.Тесты
Добавлены регресс-тесты во все затронутые наборы. Полный unit-набор: 2064 passed, 47 skipped, 0 failed.
🤖 Generated with Claude Code