Skip to content

[SITES-40704] Add suggestion data validation using shared Joi schemas#2008

Open
Kanishkavijay39 wants to merge 7 commits intomainfrom
suggestion-data-validation
Open

[SITES-40704] Add suggestion data validation using shared Joi schemas#2008
Kanishkavijay39 wants to merge 7 commits intomainfrom
suggestion-data-validation

Conversation

@Kanishkavijay39
Copy link
Contributor

Validate suggestion data against DATA_SCHEMAS before creating or updating suggestions in syncSuggestions. Invalid data is skipped with a warning log to prevent bad data from persisting.

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes
  • If data sources for any opportunity has been updated/added, please update the wiki for same opportunity.

Related Issues

Thanks for contributing!

Kanishka and others added 2 commits February 18, 2026 16:42
Validate suggestion data against DATA_SCHEMAS before creating
or updating suggestions in syncSuggestions. Invalid data is
skipped with a warning log to prevent bad data from persisting.
Validate suggestion data against DATA_SCHEMAS before creating
or updating suggestions in syncSuggestions. Invalid data is
logged as a warning to provide observability into data quality.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link

This PR will trigger no release when merged.

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Kanishka and others added 5 commits February 19, 2026 17:56
Extract warnOnInvalidSuggestionData utility and apply it to
Suggestion.create(), addSuggestions(), and setData()+save() calls
across 15 handler files for consistent validation coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Added getType() method to opportunity mocks in accessibility and
structured-data tests to ensure warnOnInvalidSuggestionData validation
logic is properly exercised and achieves 100% code coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Added getType() method to opportunity mocks in high-organic-low-ctr,
no-cta-above-the-fold, prerender, and readability guidance handler tests
to achieve 100% code coverage for validation logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
Added getType() method to all opportunity mocks that use addSuggestions
in image-alt-text opportunity-handler tests to achieve 100% branch
coverage for validation logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
Added getType() method to opportunity mocks in 8 failing tests:
- accessibility: 2 tests (without htmlWithIssues, multiple remediations)
- experimentation-opportunities: 2 tests (new opportunity, validation)
- prerender: 1 test (null getData)
- broken-links guidance: 1 test
- high-organic-low-ctr: 2 tests (system-managed, legacy)

This completes 100% test coverage for the validation implementation.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant