Skip to content

feat(google-places): source API key from MP config first, env var as fallback#14

Merged
chriskehayias merged 1 commit into
mainfrom
feat/google-places-mp-config-key
May 21, 2026
Merged

feat(google-places): source API key from MP config first, env var as fallback#14
chriskehayias merged 1 commit into
mainfrom
feat/google-places-mp-config-key

Conversation

@chriskehayias
Copy link
Copy Markdown
Contributor

Summary

  • GooglePlacesService now resolves the API key from dp_Configuration_Settings (Application_Code='COMMON', Key_Name='GoogleMapsAPIKey') before falling back to GOOGLE_PLACES_API_KEY. If neither is set, the feature stays disabled exactly as before.
  • The resolved key is cached on the singleton — MP is queried at most once per process. MP lookup failures are swallowed so a permissions issue can't shadow the env-var fallback.
  • isEnabled() and getProvider() are now async; the single sync caller in addeditfamily/actions.ts was updated. .env.example documents the new precedence.

Test plan

  • In MP, set dp_Configuration_Settings.Value for Application_Code='COMMON'/Key_Name='GoogleMapsAPIKey' and confirm the Add/Edit Family address autocomplete works with that key (and not the env var).
  • Clear the MP setting, leave GOOGLE_PLACES_API_KEY set in .env.local, confirm autocomplete still works (env-var fallback).
  • Clear both, confirm the address field gracefully falls back to a plain text input (no error, no dropdown).
  • Verify the MP lookup only fires once per process (e.g. multiple autocomplete keystrokes don't re-query dp_Configuration_Settings).

🤖 Generated with Claude Code

…fallback

Reworks GooglePlacesService key resolution to prefer the
dp_Configuration_Settings row (Application_Code='COMMON',
Key_Name='GoogleMapsAPIKey') before falling back to the
GOOGLE_PLACES_API_KEY environment variable. When neither is set the
feature stays disabled and the address autocomplete UI falls back to a
plain text input as before.

- Service now holds an MPHelper and a resolveApiKey() helper that caches
  the lookup on the singleton (MP is queried at most once per process).
- isEnabled() and getProvider() are now async; MP lookup failures are
  swallowed so a permissions issue does not break the env-var fallback.
- Updates the one synchronous caller in addeditfamily/actions.ts.
- Documents the new precedence order in .env.example.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chriskehayias chriskehayias merged commit b35c15e into main May 21, 2026
1 check passed
@chriskehayias chriskehayias deleted the feat/google-places-mp-config-key branch May 21, 2026 05:56
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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