Skip to content

Fix crash when stored playground language state is invalid#3646

Open
martin-henz wants to merge 6 commits into
masterfrom
invalidLang
Open

Fix crash when stored playground language state is invalid#3646
martin-henz wants to merge 6 commits into
masterfrom
invalidLang

Conversation

@martin-henz
Copy link
Copy Markdown
Member

@martin-henz martin-henz commented Mar 10, 2026

AI-generated PR, fixing #3645

Generated with Claude Code, Sonnet 4.6.

Description

Validate the stored chapter+variant combination against ALL_LANGUAGES when loading from localStorage. Falls back to the default language config if the combination is invalid (e.g. chapter 1 + explicit-control).

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Start frontend using localhost, switch to conductor in feature flags, choose Source 1. Then reload in the browser. This would crash the frontend when the feature flag is reset to false, because the "Source 1" language does not have a CSE machine implementation.

Checklist

  • I have tested this code
  • I have updated the documentation

Validate the stored chapter+variant combination against ALL_LANGUAGES
when loading from localStorage. Falls back to the default language config
if the combination is invalid (e.g. chapter 1 + explicit-control).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

This works but behaves differently than what the issue suggests.

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 10, 2026

Coverage Report for CI Build 24697879728

Coverage increased (+0.02%) to 40.826%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 5 of 5 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13827
Covered Lines: 6098
Line Coverage: 44.1%
Relevant Branches: 7010
Covered Branches: 2409
Branch Coverage: 34.37%
Branches in Coverage %: Yes
Coverage Strength: 28.82 hits per line

💛 - Coveralls

@martin-henz
Copy link
Copy Markdown
Member Author

This works but behaves differently than what the issue suggests.

In what way is this different from what the issue suggests?

@RichDom2185
Copy link
Copy Markdown
Member

This works but behaves differently than what the issue suggests.

In what way is this different from what the issue suggests?

The issue suggests:

invalid combination of lang + variant → fallback to default lang + variant combination

But the logic implemented is:

invalid lang → fallback to default lang && invalid variant → fallback to default variant

@martin-henz
Copy link
Copy Markdown
Member Author

This works but behaves differently than what the issue suggests.

In what way is this different from what the issue suggests?

The issue suggests:

invalid combination of lang + variant → fallback to default lang + variant combination

But the logic implemented is:

invalid lang → fallback to default lang && invalid variant → fallback to default variant

Hmm, the implementation checks:

          const validCombination = ALL_LANGUAGES.some(
            lang => lang.chapter === chapter && lang.variant === variant
          );

so it looks for a valid combination. It falls back on the default lang/variant only if the combination is not valid.

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.

3 participants