Skip to content

Conversation

@VierlingMt
Copy link

No description provided.

@Apollon77 Apollon77 requested a review from Copilot October 3, 2025 23:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a null reference error where state.val could be null when calling toLowerCase() method. The fix adds proper null checking and input validation for the favorites_set state handler.

  • Added null safety by converting state.val to string with fallback to empty string
  • Added validation to skip processing when no valid favorite name is provided
  • Replaced direct state.val usage with the sanitized fav variable

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +190 to +211
if (!fav) {
adapter.log.warn('favorites_set called without valid favorite name – skipped');
} else {
promise = player
.replaceWithFavorite(fav)
.then(() => player.play())
.then(() => {
adapter.setState(
{ device: 'root', channel: id.channel, state: 'current_album' },
{ val: fav, ack: true }
);
adapter.setState(
{
device: 'root',
channel: id.channel,
state: 'current_artist'
},
{ val: fav, ack: true }
);
})
.catch(error => adapter.log.error(`Cannot replaceWithFavorite: ${error}`));
}
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: this line uses tabs while the surrounding code uses spaces. Should use spaces to match the existing code style.

Copilot uses AI. Check for mistakes.
Comment on lines +190 to +211
if (!fav) {
adapter.log.warn('favorites_set called without valid favorite name – skipped');
} else {
promise = player
.replaceWithFavorite(fav)
.then(() => player.play())
.then(() => {
adapter.setState(
{ device: 'root', channel: id.channel, state: 'current_album' },
{ val: fav, ack: true }
);
adapter.setState(
{
device: 'root',
channel: id.channel,
state: 'current_artist'
},
{ val: fav, ack: true }
);
})
.catch(error => adapter.log.error(`Cannot replaceWithFavorite: ${error}`));
}
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: these lines use tabs while the surrounding code uses spaces. Should use spaces to match the existing code style.

Copilot uses AI. Check for mistakes.
Comment on lines +190 to +210
if (!fav) {
adapter.log.warn('favorites_set called without valid favorite name – skipped');
} else {
promise = player
.replaceWithFavorite(fav)
.then(() => player.play())
.then(() => {
adapter.setState(
{ device: 'root', channel: id.channel, state: 'current_album' },
{ val: fav, ack: true }
);
adapter.setState(
{
device: 'root',
channel: id.channel,
state: 'current_artist'
},
{ val: fav, ack: true }
);
})
.catch(error => adapter.log.error(`Cannot replaceWithFavorite: ${error}`));
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: this line uses tabs while the surrounding code uses spaces. Should use spaces to match the existing code style.

Copilot uses AI. Check for mistakes.
);
})
.catch(error => adapter.log.error(`Cannot replaceWithFavorite: ${error}`));
}
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: this line uses tabs while the surrounding code uses spaces. Should use spaces to match the existing code style.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
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