Skip to content

fix(google-ads): fix campaign and keyword metrics validation errors and ROAS calculations#167

Merged
AlexanderHeffernan merged 1 commit into
masterfrom
ah/google-ads-fixes
Feb 12, 2026
Merged

fix(google-ads): fix campaign and keyword metrics validation errors and ROAS calculations#167
AlexanderHeffernan merged 1 commit into
masterfrom
ah/google-ads-fixes

Conversation

@AlexanderHeffernan
Copy link
Copy Markdown
Contributor

Description

  • Purpose: Fix data format validation errors and incorrect ROAS calculations in Google Ads campaign and keyword metrics retrieval.
  • Approach: Wrap API responses in the expected schema format and correct the default value for missing cost data to prevent calculation errors.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Updates

👉 Wrapped retrieve_campaign_metrics and retrieve_keyword_metrics responses in {"results": ...} object to match expected output schema and fix production ValidationError
👉 Changed default cost_micros value from 1 to 0 when missing to prevent incorrect Return On Ad Spend (ROAS) calculations
👉 Applied consistent response format across both campaign and keyword metrics endpoints

Screenshots

N/A

Test plan

  1. Test retrieve_campaign_metrics action with valid customer ID and verify response format matches {"results": [...]} schema
  2. Test retrieve_keyword_metrics action with valid parameters and verify response format is correct
  3. Verify ROAS calculations are accurate when cost_micros is missing (should be 0, not inflated by default value of 1)
  4. Confirm no ValidationErrors occur in production when these actions are executed

Author(s) to check

  • Project and all contained modules builds successfully
  • Self-/dev-tested
  • Unit/UI/Automation/Integration tests provided where applicable
  • Code is written to standards
  • Appropriate documentation written (code comments, internal docs)

…ata format

- Wrap retrieve_campaign_metrics response in {"results": ...} to match the
  expected output schema (fixes ValidationError in production)
- Apply the same fix to retrieve_keyword_metrics (same issue)
- Default cost_micros to 0 instead of 1 when missing, preventing incorrect
  Return On Ad Spend calculations
@AlexanderHeffernan AlexanderHeffernan merged commit e90b108 into master Feb 12, 2026
1 check passed
@AlexanderHeffernan AlexanderHeffernan deleted the ah/google-ads-fixes branch February 12, 2026 01:24
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.

2 participants