Skip to content

Fix: handle unsupported locale in JokeSkill without NPE#414

Draft
mretallack wants to merge 1 commit intoDicioTeam:mainfrom
mretallack:fix/joke-skill-npe
Draft

Fix: handle unsupported locale in JokeSkill without NPE#414
mretallack wants to merge 1 commit intoDicioTeam:mainfrom
mretallack:fix/joke-skill-npe

Conversation

@mretallack
Copy link
Copy Markdown

When the user changes language, there is a race condition where JokeSkill.generateOutput() can be called with a locale not in JOKE_SUPPORTED_LOCALES. This happened because the SkillRanker still holds the old JokeSkill instance while ctx.locale already reflects the new locale.

The !! on resolveSupportedLocale() caused a NullPointerException. Replace with a safe return of JokeOutput.Failed.

Fixes the crash reported in #412 where changing language on first install causes an NPE in JokeSkill.

  • Add JokeOutput.Failed variant with user-friendly message
  • Add regression test proving the NPE scenario

When the user changes language, there is a race condition where
JokeSkill.generateOutput() can be called with a locale not in
JOKE_SUPPORTED_LOCALES. This happened because the SkillRanker still
holds the old JokeSkill instance while ctx.locale already reflects
the new locale.

The !! on resolveSupportedLocale() caused a NullPointerException.
Replace with a safe return of JokeOutput.Failed.

Fixes the crash reported in DicioTeam#412 where
changing language on first install causes an NPE in JokeSkill.

- Add JokeOutput.Failed variant with user-friendly message
- Add regression test proving the NPE scenario
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