Skip to content

fix: utility for marking suggestions as covered#1810

Open
dipratap wants to merge 6 commits into
mainfrom
ivl2
Open

fix: utility for marking suggestions as covered#1810
dipratap wants to merge 6 commits into
mainfrom
ivl2

Conversation

@dipratap

Copy link
Copy Markdown
Contributor

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

Related Issues

Thanks for contributing!

@dipratap dipratap requested a review from MysticatBot July 14, 2026 14:08
@github-actions

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@dipratap dipratap requested a review from ssilare-adobe July 14, 2026 14:08

@MysticatBot MysticatBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dipratap,

⚠ Degraded review - no spec document was found for this change (searched the PR links, the touched repos' docs, the architecture/guidelines docs, and linked Jira). This review covers code-level quality but could not validate the change against an agreed design, so confidence is reduced. Add a spec link (PR template section 4) and re-request review for a full-confidence pass.

Verdict: Request changes - tests assert saveMany behavior that saveSuggestions does not produce given the current PARALLEL_SAVE_THRESHOLD, and the new public method lacks error handling present in the original code path.
Complexity: MEDIUM - medium-size refactoring across 3 files.
Changes: Extracts suggestion-coverage filtering into a shared findCoveredSuggestions utility and adds a new markPatternCoveredSuggestions public method on TokowakaClient (3 files).

Must fix before merge

  1. [Critical] Tests assert saveMany is called but saveSuggestions takes the individual-save/SQS path with the current threshold - test mocks also lack .save() method, causing TypeError - packages/spacecat-shared-tokowaka-client/test/index.test.js:181

    Tests assert client.dataAccess.Suggestion.saveMany.calledOnceWith(covered) but saveSuggestions with the current PARALLEL_SAVE_THRESHOLD value enters the individual-save path (Promise.allSettled(suggestions.map(s => s.save()))) rather than calling saveMany. The mkCovered mock objects lack a .save() method, so this path throws TypeError: s.save is not a function.

    Fix options:

    • Add save: sinon.stub().resolves() to mkCovered and assert on individual .save() calls instead of saveMany.
    • Set up client.sqs and client.importWorkerQueueUrl in the test fixture (as the bulk-update test already does) so the SQS path is taken, and assert on sqs.sendMessage.
    • If saveMany is the intended path for small batches, verify the threshold value allows it.
  2. [Important] Missing error handling around saveSuggestions - the original deployPatternSuggestion wraps saves in try/catch with a warning log; the new method propagates unhandled - packages/spacecat-shared-tokowaka-client/src/index.js:1766

    The original code wraps saveSuggestions in a try/catch that logs a warning and continues gracefully on failure. The new markPatternCoveredSuggestions has no equivalent guard - a save failure (SQS down, DB error) propagates as an unhandled rejection, which could abort the caller's entire batch operation.

    Fix: Either add a try/catch with a warning log (matching the established resilience pattern), or document in the JSDoc that callers are responsible for error handling (@throws on save failure).

Non-blocking (4): minor issues and suggestions
  • nit: Commit type fix: may be more appropriate as feat: since a new public method and exported utility are added (conventional commits required per CLAUDE.md) - PR title
  • suggestion: Add dedicated unit tests for findCoveredSuggestions in test/utils/suggestion-utils.test.js to mirror src/ structure per CLAUDE.md convention and cover branches not exercised through the client (excludeIds, edgeDeployed skip, invalid regex patterns) - packages/spacecat-shared-tokowaka-client/test/utils/suggestion-utils.test.js
  • nit: patternSuggestion.getData() called twice in markPatternCoveredSuggestions - store once and reference for both allowedRegexPatterns and isDomainWide - packages/spacecat-shared-tokowaka-client/src/index.js:1741
  • suggestion: The [edge-deploy] log prefix in markPatternCoveredSuggestions may be misleading when called from the launch-time cover-marking flow; consider a more generic prefix or a caller-supplied label - packages/spacecat-shared-tokowaka-client/src/index.js:1783

Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 3m 12s | Cost: $7.62 | Commit: 3c404b5902e6f9a1cbde2ac9eb8a729583c0d8ac
If this code review was useful, please react with 👍. Otherwise, react with 👎.

@MysticatBot MysticatBot added ai-reviewed Reviewed by AI complexity:medium AI-assessed PR complexity: MEDIUM labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed Reviewed by AI complexity:medium AI-assessed PR complexity: MEDIUM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants