Conversation
|
This PR will trigger a patch release when merged. |
There was a problem hiding this comment.
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
-
[Critical] Tests assert
saveManyis called butsaveSuggestionstakes 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:181Tests assert
client.dataAccess.Suggestion.saveMany.calledOnceWith(covered)butsaveSuggestionswith the currentPARALLEL_SAVE_THRESHOLDvalue enters the individual-save path (Promise.allSettled(suggestions.map(s => s.save()))) rather than callingsaveMany. ThemkCoveredmock objects lack a.save()method, so this path throwsTypeError: s.save is not a function.Fix options:
- Add
save: sinon.stub().resolves()tomkCoveredand assert on individual.save()calls instead ofsaveMany. - Set up
client.sqsandclient.importWorkerQueueUrlin the test fixture (as the bulk-update test already does) so the SQS path is taken, and assert onsqs.sendMessage. - If
saveManyis the intended path for small batches, verify the threshold value allows it.
- Add
-
[Important] Missing error handling around
saveSuggestions- the originaldeployPatternSuggestionwraps saves in try/catch with a warning log; the new method propagates unhandled -packages/spacecat-shared-tokowaka-client/src/index.js:1766The original code wraps
saveSuggestionsin a try/catch that logs a warning and continues gracefully on failure. The newmarkPatternCoveredSuggestionshas 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 (
@throwson save failure).
Non-blocking (4): minor issues and suggestions
- nit: Commit type
fix:may be more appropriate asfeat:since a new public method and exported utility are added (conventional commits required per CLAUDE.md) - PR title - suggestion: Add dedicated unit tests for
findCoveredSuggestionsintest/utils/suggestion-utils.test.jsto mirrorsrc/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 inmarkPatternCoveredSuggestions- store once and reference for bothallowedRegexPatternsandisDomainWide-packages/spacecat-shared-tokowaka-client/src/index.js:1741 - suggestion: The
[edge-deploy]log prefix inmarkPatternCoveredSuggestionsmay 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 👎.
Please ensure your pull request adheres to the following guidelines:
Related Issues
Thanks for contributing!