fix: halt doChorus, doTremolo, doDistortion when depth/distortion validation fails - #7979
Open
Abhishek-Sonje wants to merge 1 commit into
Conversation
Abhishek-Sonje
requested review from
Ashutoshx7,
pikurasa and
walterbender
as code owners
August 6, 2026 10:53
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime bug in the tone-effects action layer (Singer.ToneActions) where validation failures would still fall through and mutate turtle singer state / register listeners, despite setting activity.logo.stopTurtle = true.
Changes:
- Added early
returnstatements after invalid depth/distortion validation indoChorus,doTremolo, anddoDistortion. - Strengthened Jest coverage to assert the relevant singer state arrays remain unchanged when validation fails.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| js/turtleactions/ToneActions.js | Adds early returns to prevent state mutation/listener registration after validation errors in chorus/tremolo/distortion actions. |
| js/turtleactions/tests/ToneActions.test.js | Extends regression tests to assert singer state arrays remain empty when validation fails. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Singer.ToneActions.doChorus,doTremolo, anddoDistortionvalidate their depth/distortion parameter, but when validation fails, each function only displays an error message and setsactivity.logo.stopTurtle = true. Since execution does not stop immediately, the function continues and updates the turtle's singer state with the invalid value, and registers a playback listener regardless.This change adds early returns after each validation check so that the functions exit immediately when invalid input is detected.
Related Issue
This PR fixes #7978
PR Category
Changes Made
returnafter the invalid depth validation inSinger.ToneActions.doChorus.returnafter the invalid depth validation inSinger.ToneActions.doTremolo.returnafter the invalid distortion validation inSinger.ToneActions.doDistortion.(previously the tests only checked that
errorMsgfired andstopTurtlewas set, so they passed even with the fall-through bug in place).Testing Performed
Ran: npx jest js/turtleactions/tests/ToneActions.test.js
Confirmed the new/updated assertions fail against the unpatched functions
(proving they catch the leak), and pass after adding the
returns.Confirmed valid chorus/tremolo/distortion values still work as expected.
Confirmed invalid parameters display the existing error message and no
longer modify turtle state or register a listener.
Checklist
npm run lintandnpx prettier --check .with no errors.Additional Notes for Reviewers
Same root cause as #7921, fixed for
doVibratoin #7922 — this PR applies the identical fix to three sibling effect functions in the same file (js/turtleactions/ToneActions.js) discovered while auditing for similarstopTurtle = true-without-returnpatterns.