Skip to content

Register enum converter for CheckoutVariant in sample#194

Merged
kirich1409 merged 2 commits into
developfrom
fix/sample-enum-converter
May 18, 2026
Merged

Register enum converter for CheckoutVariant in sample#194
kirich1409 merged 2 commits into
developfrom
fix/sample-enum-converter

Conversation

@kirich1409
Copy link
Copy Markdown
Contributor

What crashed

SampleFeatureFlags.checkoutVariant is an enum-typed ConfigParam<CheckoutVariant> observed via DataStoreConfigValueProvider. DataStore's preferences API only supports six primitive types (String, Int, Long, Float, Double, Boolean). When observe() was called for the enum param, it fell through to createPreferencesKey, hit the else branch, and threw IllegalArgumentException: Unsupported type: class dev.androidbroadcast.featured.CheckoutVariant, crashing the process on launch.

Fix

Register enumConverter<CheckoutVariant>() on the DataStoreConfigValueProvider instance before constructing ConfigValues in MainActivity. Since defaultLocalProvider(context) returns LocalConfigValueProvider (the interface), a safe cast to DataStoreConfigValueProvider is used to call registerConverter.

Also adds implementation(project(":providers:datastore")) to sample/android-app/build.gradle.kts — the :providers:datastore module is an implementation (not api) dependency of :featured-platform, so its symbols are not transitively visible to the app module.

Scope

Sample-only patch. No library code is changed.

Library-level error handling (catching IllegalArgumentException in observe() so a missing converter fails gracefully rather than crashing) is tracked in the sibling PR fix/configvalues-observe-catch.

kirich1409 and others added 2 commits May 18, 2026 13:38
The sample observes an enum-typed flag (CheckoutVariant) via
DataStoreConfigValueProvider, but never registered a TypeConverter
for the enum. DataStore preferences only support primitive keys, so
observation crashed with IllegalArgumentException on launch. Register
enumConverter<CheckoutVariant>() on the provider before building
ConfigValues.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Register every flag in SampleFeatureFlags with FlagRegistry on
Application start so the Debug UI renders the list instead of
the empty state. Apply statusBarsPadding() to the home-screen
top row so the "Debug flags" button is reachable under
enableEdgeToEdge.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@kirich1409 kirich1409 force-pushed the fix/sample-enum-converter branch from 8f9458d to e01b332 Compare May 18, 2026 10:38
@kirich1409 kirich1409 marked this pull request as ready for review May 18, 2026 10:52
Copilot AI review requested due to automatic review settings May 18, 2026 10:52
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@kirich1409 kirich1409 merged commit b734f8b into develop May 18, 2026
10 checks passed
Copy link
Copy Markdown

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 the Android sample crash when observing the enum-backed checkoutVariant flag through the DataStore provider by registering the enum converter before creating ConfigValues.

Changes:

  • Registers sample flags for debug UI discovery.
  • Registers CheckoutVariant DataStore converter in MainActivity.
  • Adds the DataStore provider dependency and applies status bar padding to the sample screen.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sample/shared/src/commonMain/kotlin/dev/androidbroadcast/featured/SampleApp.kt Adds registerSampleFlags() to populate FlagRegistry.
sample/shared/src/commonMain/kotlin/dev/androidbroadcast/featured/FeaturedSample.kt Adds status bar padding to the sample screen layout.
sample/android-app/src/main/kotlin/dev/androidbroadcast/featured/sample/MainActivity.kt Registers sample flags and the CheckoutVariant DataStore enum converter before creating ConfigValues.
sample/android-app/build.gradle.kts Adds a direct dependency on :providers:datastore.

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.

2 participants