Skip to content

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

Merged
cameronapak merged 11 commits into
mainfrom
YPE-1565-missing-app-key-error
Jul 7, 2026
Merged

YPE-1565: Show error when YouVersionProvider has no appKey#264
cameronapak merged 11 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 surfaces a clear error when YouVersionProvider is given a missing or empty appKey, replacing the previous blank-page failure mode. The UI package renders a styled MissingAppKey panel with i18n support, while the hooks package throws a descriptive error (for hooks-only consumers who own their own error boundary).

  • Hooks provider is split into a thin YouVersionProvider wrapper (validates appKey, throws if invalid) and an inner YouVersionProviderInner that owns all hook calls, keeping hook order consistent across renders regardless of key validity.
  • UI provider detects the missing key before calling the base provider, logs to console.error from an effect (avoiding Strict Mode double-calls), and renders the MissingAppKey panel with YvStyles scoped styles and proper role="alert" semantics.
  • Tests, Storybook story, i18n translations (en/fr/es), changeset, and example cleanup are all included.

Confidence Score: 5/5

Safe to merge. The two-layer guard (styled panel in UI, throw in hooks) is correctly implemented, hook order is preserved by the wrapper/inner split, and all three invalid-key variants are covered by tests.

The wrapper/inner split cleanly separates the validation logic from hook-bearing code, the UI provider calls hooks unconditionally before any conditional return, and the console.error is deferred to an effect to avoid Strict Mode duplication. No logic defects were found in the changed paths.

No files require special attention.

Important Files Changed

Filename Overview
packages/hooks/src/context/YouVersionProvider.tsx Split into a thin validation wrapper and an inner hook-bearing component; the throw guard lives before any hook calls, correctly preserving hook order on every render path.
packages/ui/src/components/YouVersionProvider.tsx Adds missingAppKey guard with a useEffect-based console.error (avoids Strict Mode duplication) and renders MissingAppKey panel with resolveTheme before ever reaching the base provider.
packages/ui/src/components/missing-app-key.tsx New component with correct role="alert" semantics (no overriding aria-live), i18n via react-i18next, and scoped Tailwind classes. Uses data-yv-theme for theming.
packages/hooks/src/context/YouVersionProvider.test.tsx Adds it.each tests covering undefined, empty string, and whitespace-only appKey cases; each verifies the correct throw message.
packages/ui/src/components/YouVersionProvider.test.tsx Tests verify role="alert" presence, error heading text, child suppression, and console.error call with appKey substring for all three invalid-key variants.
packages/ui/src/components/missing-app-key.stories.tsx Adds Light, Dark, and integration stories with a play function asserting role="alert", heading, and body text.
examples/vite-react/src/ThemedApp.tsx Removes the empty-string fallback on VITE_YVP_APP_KEY, passing undefined from an unset env var as '' at the prop boundary so the provider guard triggers correctly.
.changeset/missing-app-key-message.md Correctly marks both @youversion/platform-react-hooks and @youversion/platform-react-ui as minor bumps; description is accurate.

Reviews (10): Last reviewed commit: "refactor(ui): log missing-appKey guidanc..." | 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: 434e9fe

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>
Comment thread packages/ui/src/i18n/locales/es.json
cameronapak and others added 2 commits June 24, 2026 12:46
- Remove redundant `missingAppKey*` translation keys
- Reuse generic `errorHeading` and `invalidAppKeyError` strings
- Add a `console.error` in `YouVersionProvider` for developers
The previous commit reused errorHeading/invalidAppKeyError and moved the
actionable developer guidance to console.error. Update the assertions to
match: expect "Error" instead of "Missing app key", and verify the
console.error guidance fires. Also refresh the guard comment to reflect
that the panel is intentionally generic.

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

Copy link
Copy Markdown
Collaborator Author

@Dustin-Kelley can you review this? I'm no longer adding new strings to this and re-using old ones

P.S. I'll learn the new strings process and share that with you soon

Comment thread packages/hooks/src/context/YouVersionProvider.tsx Outdated
camrun91 and others added 5 commits June 26, 2026 08:40
Splits YouVersionProvider so the missing-appKey throw lives in a thin
wrapper and the hook-bearing implementation runs in an inner component.
The inner component is never entered with an invalid key, so a mounted
provider transitioning between valid and empty appKey can't produce an
inconsistent hook count. Addresses Greptile P1 review feedback.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread examples/vite-react/src/ThemedApp.tsx
Dustin-Kelley
Dustin-Kelley previously approved these changes Jul 2, 2026
cameronapak and others added 2 commits July 7, 2026 10:27
Move the console.error out of the render body so the developer guidance
is emitted once per state change instead of on every re-render and twice
under React Strict Mode.

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

@Dustin-Kelley Dustin-Kelley left a comment

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.

💯

@cameronapak cameronapak merged commit ab38fb5 into main Jul 7, 2026
6 checks passed
@cameronapak cameronapak deleted the YPE-1565-missing-app-key-error branch July 7, 2026 15:48
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