Skip to content

YPE-1565: Show error when YouVersionProvider has no appKey#264

Open
cameronapak wants to merge 2 commits into
mainfrom
YPE-1565-missing-app-key-error
Open

YPE-1565: Show error when YouVersionProvider has no appKey#264
cameronapak wants to merge 2 commits into
mainfrom
YPE-1565-missing-app-key-error

Conversation

@cameronapak

@cameronapak cameronapak commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator
image

Empty/missing appKey rendered a blank page. Now: UI provider shows a styled "Missing app key" message; hooks provider throws.

  • Styled MissingAppKey panel + Storybook story
  • i18n (en/fr/es), example cleanup, unit + integration tests, changeset

YPE-1565

🤖 Generated with Claude Code

Greptile Summary

This PR fixes a blank-page regression (YPE-1565) when YouVersionProvider receives a missing or empty appKey. The UI package now shows a styled, i18n-aware "Missing app key" error panel instead of rendering nothing, while the hooks package throws a descriptive error for hooks-only consumers.

  • packages/ui: New MissingAppKey component with role=\"alert\", light/dark theme support, and translations in en/es/fr; YouVersionProvider intercepts the bad key before delegating to the base provider.
  • packages/hooks: Early throw before any hook calls gives hooks-only consumers a loud, actionable failure rather than a silent empty render.
  • Tests & stories: Parameterised Vitest tests cover undefined, '', and whitespace-only inputs for both providers; a Storybook play-function story validates the rendered alert.

Confidence Score: 5/5

Safe to merge — the change is a targeted guard for a misconfiguration path that previously produced a blank page, and it does not touch any production data or auth flows.

Both providers handle the three invalid-key variants correctly, the UI provider correctly places its hook call before the early return, tests cover all cases, and i18n keys are in sync across all three locale files.

No files require special attention.

Important Files Changed

Filename Overview
packages/hooks/src/context/YouVersionProvider.tsx Adds an early throw before hooks when appKey is missing/empty, providing a loud failure for hooks-only consumers; guard is placed before all hook calls
packages/ui/src/components/YouVersionProvider.tsx Guards against missing appKey by returning the styled MissingAppKey panel before delegating to BaseYouVersionProvider; useEffect is correctly placed before the early return guard
packages/ui/src/components/missing-app-key.tsx New styled error panel component with role="alert", ExclamationCircle icon, and i18n text for light/dark themes; previous aria-live conflict already addressed
packages/ui/src/components/YouVersionProvider.test.tsx New parameterized test covering undefined, empty string, and whitespace-only appKey cases; verifies alert role renders and base provider is not called
packages/hooks/src/context/YouVersionProvider.test.tsx New parameterized test covering all three invalid appKey variants; verifies the thrown error message matches expectations
packages/ui/src/components/missing-app-key.stories.tsx Storybook stories for Light, Dark, and a play-function integration story that validates role="alert" and key text are present
examples/vite-react/src/ThemedApp.tsx Removes the ?? '' default on the local variable and passes appKey ?? '' directly to the prop, with a comment explaining the intentional missing-key demo behaviour
packages/ui/src/i18n/locales/en.json Adds missingAppKeyHeading and missingAppKeyBody keys to English locale
packages/ui/src/i18n/locales/es.json Adds translated missingAppKeyHeading and missingAppKeyBody keys to Spanish locale
packages/ui/src/i18n/locales/fr.json Adds translated missingAppKeyHeading and missingAppKeyBody keys to French locale
.changeset/missing-app-key-message.md Minor changeset for both hooks and ui packages; description accurately summarises the UX change

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[YouVersionProvider called] --> B{appKey empty / whitespace?}
    B -- Yes, UI package --> C[Return YvStyles + MissingAppKey panel]
    B -- Yes, hooks package --> D[throw Error non-empty appKey required]
    B -- No --> E[Normal render path]
    E -- UI package --> F[BaseYouVersionProvider + YvStyles + children]
    E -- hooks package --> G[useResolvedTheme + context setup + children]
    D --> H[Nearest ErrorBoundary or app crash]
    C --> I[Styled alert panel with i18n message]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[YouVersionProvider called] --> B{appKey empty / whitespace?}
    B -- Yes, UI package --> C[Return YvStyles + MissingAppKey panel]
    B -- Yes, hooks package --> D[throw Error non-empty appKey required]
    B -- No --> E[Normal render path]
    E -- UI package --> F[BaseYouVersionProvider + YvStyles + children]
    E -- hooks package --> G[useResolvedTheme + context setup + children]
    D --> H[Nearest ErrorBoundary or app crash]
    C --> I[Styled alert panel with i18n message]
Loading

Reviews (2): Last reviewed commit: "fix(ui): remove redundant aria-live on a..." | Re-trigger Greptile

Render a styled "Missing app key" message instead of a blank page; hooks
provider throws for hooks-only consumers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 243cf88

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-react-hooks Minor
@youversion/platform-react-ui Minor
vite-react Patch
@youversion/platform-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/ui/src/components/missing-app-key.tsx Outdated
role="alert" already implies aria-live="assertive"; the explicit
polite value downgraded announcement urgency for a config error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hey @camrun91, what do we do about locales that we add that aren't yet Crowdin translated? Do we put in potential strings or leave those in English in these locale files?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What do you mean new locals? If you are talking adding new strings the process will be to add them to the file in the localization repo. This is a good test to find out the best way to do this as the english source files shouldn't need to be translated and we need a process to make this quicker

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