fix(cli): enforce micro-ruble money inputs#400
Conversation
Co-authored-by: Cursor <[email protected]>
|
@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 4m 37s —— View job Claude PR Review — critical-issues pass
SummaryFocused on bugs, security, logic, data loss, perf. Found one real defect (stale help text that actively contradicts the new contract) and no security/data-loss concerns. The contract flip itself is well-tested. Findings🟠 1. Four flags ship stale help text that contradicts the new contract —
|
The four AVERAGE_ROI flags (--text-search-roi-coef, --text-search-profitability, --text-network-roi-coef, --text-network-profitability) switched from RUBLES_TO_MICRO_RUBLES to MICRO_RUBLES but their help text still said "Input is multiplied by 1,000,000", which contradicted the new contract: MICRO_RUBLES expects the pre-multiplied wire-format integer and does no conversion. Rewrite the help to say the value is supplied directly in micro-rubles wire format (matches the wording used by the neighboring *-exploration-min-budget flags), and extend the test_direct_money_flags_use_micro_rubles_only guard to forbid "multiplied by 1,000,000" so the same drift is caught next time. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@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 3m 25s —— View job Claude PR Review — critical-issues pass
SummaryNo critical issues. The stale help-text defect flagged in my previous pass ( The contract flip itself remains clean — see verifications below. Verified
Observation (not blocking, pre-existing, out of scope)
This inconsistency exists on RecommendationLGTM for merge on the critical-issues criteria you asked for: no bugs, no security concerns, no data-loss risk, no perf regression. Contract flip is well-tested and behaviorally tight. · branch |
Bump version to 0.3.13 for PyPI release. CHANGELOG covers: - Breaking: micro-ruble money inputs for campaign bidding-strategy and ads price-extension flags (#399, #400). - All 0.3.12 additions (callouts on ads update, tracking params and negative keywords on adgroups, video/price extensions on ads, UnifiedCampaign/SmartCampaign/TextCampaign/DynamicTextCampaign/MobileApp /CPMBanner bidding strategy typed flags, milestone 19 audit close). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* fix(campaigns): priority-goals Value enforced as micro-currency Per Yandex Direct API contract (add-text-campaign, strategies-types), PriorityGoalsItem.Value is xsd:long in advertiser currency × 1,000,000 — the same micro-currency contract as --budget and other money flags after #399/#400. Previously parse_priority_goals_spec accepted raw integers and forwarded them unchanged, so --priority-goals 1:500 emitted Value: 500 which the API interprets as 0.0005 currency units. - direct_cli/utils.py: parse_priority_goals_spec rejects negative values and values below MICRO_RUBLE_MIN with a helpful "Did you mean N×1,000,000?" suggestion. - direct_cli/commands/campaigns.py: --priority-goals help text now documents the micro-currency contract on both option declarations (add + update). - direct_cli/_bidding_strategy.py: removed the obsolete "KNOWN ISSUE #387" comment. - tests/test_dry_run.py: bumped all priority-goals fixture values to realistic micro-currency amounts (20→20000000 etc.) and added two reject tests: sub-MICRO_RUBLE_MIN value and negative value. Closes #387. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(strategies): apply priority-goal micro-currency validation `direct strategies add` / `direct strategies update` build PriorityGoals.Items via a separate parser (`_parse_priority_goal`) which forwarded `Value` as a raw int — same #387 data-loss class as the campaigns side. Per WSDL (tests/wsdl_cache/strategies.xml lines 503-509), PriorityGoalsItem.Value is xsd:long advertiser currency × 1,000,000 for standalone Strategy* items too, so the contract is shared and the validation must be too. - Extract `validate_priority_goal_value(value_int, error_prefix)` in utils.py from the campaign-side parser (single source of truth for the < 0 and 0 < v < MICRO_RUBLE_MIN guards, plus the `Did you mean N×1,000,000?` hint). - Call it from `_parse_priority_goal` in strategies.py so `direct strategies add ... --priority-goal 1:500` is now rejected at CLI parse time instead of silently sending Value=500 (≈0.0005 RUB). - Update help text on both `--priority-goal` decorators to document the micro-currency contract. - Add `test_strategies_add_rejects_priority_goal_value_below_micro_min` and `test_strategies_update_rejects_priority_goal_negative_value` parallel to the campaigns reject tests. Now genuinely Closes #387 (review-found sibling bug on the strategies surface). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test: update api_coverage priority-goals fixtures to micro-currency Six PAYLOAD_CASES fixtures in tests/api_coverage_payloads.py still used raw-ruble Value (e.g. ``1234567:80``) which the new parse_priority_goals_spec validator rejects as below MICRO_RUBLE_MIN. Bump them to ``1234567:80000000,9876543:20000000`` to match the post-#387 contract — same change the first commit made for tests/test_dry_run.py fixtures. This unblocks CI: test_dry_run_payload_schema_coverage[ campaigns-add-argv48,53,54,55,56] and test_dry_run_payload_schema_coverage[campaigns-update-argv57], plus the three cascading schema-gate tests. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: axisrow <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Test plan
pytest tests/test_dry_run.pypytest tests/test_cli.pypytest tests/test_wsdl_parity_gate.py tests/test_api_coverage.pyrgguards for old ruble conversion wording andRUBLES_TO_MICRO_RUBLESMade with Cursor