Skip to content

fix: guard against numeric noteArg in getNote()#7452

Open
Gungunverma1227 wants to merge 2 commits into
sugarlabs:masterfrom
Gungunverma1227:fix-getnote-typeguard-clean
Open

fix: guard against numeric noteArg in getNote()#7452
Gungunverma1227 wants to merge 2 commits into
sugarlabs:masterfrom
Gungunverma1227:fix-getnote-typeguard-clean

Conversation

@Gungunverma1227

@Gungunverma1227 Gungunverma1227 commented Jun 1, 2026

Copy link
Copy Markdown

Problem

When a custom temperament is active, pitch blocks pass integer step indices to getNote(). The function internally calls .substr() assuming a string argument, causing a crash:
TypeError: noteArg.substr is not a function

Fix

Added a type guard at the entry of getNote() in musicutils.js to convert numeric noteArg to string before processing.

Category

  • Bug Fix

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

🧪 Jest Test Results

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Coverage: Statements: 46.79% | Branches: 38.27% | Functions: 51.22% | Lines: 47.22%
Master Coverage: Statements: 48.23% | Branches: 39.77% | Functions: 52.95% | Lines: 48.62%

Note: These failures may be introduced by this PR or may already exist in the master branch.
Tip: Update your branch with the latest master and rerun tests.
If the same failures are present on master, they are likely not introduced by this PR.

Failed Tests:

arpeggio.test.js

@021nirav-blip

Copy link
Copy Markdown
Contributor

@Gungunverma1227, can you add the PR category correctly, other than that your changes looks good to me

@github-actions github-actions Bot added bug fix Fixes a bug or incorrect behavior size/XS Extra small: < 10 lines changed area/javascript Changes to JS source files labels Jun 5, 2026
@Gungunverma1227

Copy link
Copy Markdown
Author

@021nirav-blip Thank you! I have added the PR category correctly. Could you please approve the review?

@021nirav-blip 021nirav-blip left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@walterbender

Copy link
Copy Markdown
Member

Please address the linting errors

@021nirav-blip

Copy link
Copy Markdown
Contributor

@Gungunverma1227
rebase to latest master branch and fix the linting error

@Gungunverma1227 Gungunverma1227 force-pushed the fix-getnote-typeguard-clean branch from 0b5b0cc to d47b4eb Compare June 7, 2026 11:52
@Gungunverma1227

Copy link
Copy Markdown
Author

@walterbender @021nirav-blip I have rebased to the latest master branch and fixed the linting errors. Please review!

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🧪 Jest Test Results

✅ All Jest tests passed! This PR is ready to merge.

Coverage: Statements: 48.3% | Branches: 39.91% | Functions: 53.01% | Lines: 48.7%
Master Coverage: Statements: 48.3% | Branches: 39.91% | Functions: 53.01% | Lines: 48.7%

Comment thread js/utils/musicutils.js Outdated
) {
if (typeof noteArg === "number") {
noteArg = noteArg.toString();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This indentation doesn't look correct

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@walterbender I have fixed the indentation. Please review!

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🧪 Jest Test Results

✅ All Jest tests passed! This PR is ready to merge.

Coverage: Statements: 48.3% | Branches: 39.91% | Functions: 53.01% | Lines: 48.7%
Master Coverage: Statements: 48.3% | Branches: 39.91% | Functions: 53.01% | Lines: 48.7%

@Gungunverma1227

Gungunverma1227 commented Jun 9, 2026

Copy link
Copy Markdown
Author

@walterbender @021nirav-blip please review , i have updated the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/javascript Changes to JS source files bug fix Fixes a bug or incorrect behavior size/XS Extra small: < 10 lines changed

Projects

Development

Successfully merging this pull request may close these issues.

3 participants