fix: stop CI failing on forked PRs for want of a geocoding key - #908
Conversation
CircleCI does not pass project environment variables to jobs built from forked pull requests, so GOOGLE_API_CONSOLE_KEY is empty on those runs. Every geocode then returns false, group creation 422s on groups.geocode_failed, and the Playwright suite fails at its first createGroup() - so all 50 tests fail and the job times out, looking exactly like the contributor having broken something. That is what is happening on #906, whose diff removes eleven unused component registrations and cannot affect group creation at all: none of the changed components is reachable from the create page. Adds a StubGeocoder answering from a fixed table, used only when GEOCODER_STUB is set, which CI sets only when it has no key. It keeps the ForceGeocodeFailure sentinel failing, and falls back to London for an unlisted place so a new test fails on what it is testing rather than on the stub. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
613788a to
1ca8e77
Compare
|
Verified the stub path rather than assuming it, since this repo's own runs always have the real key and so never exercise it. Pushed a throwaway commit forcing So the container really did resolve the stub, and the full Playwright suite passed with it in play — which is what a forked PR will get. That commit is now dropped; the branch is back to the clean version, which had already passed green on its own (pipeline #5007). |
|
|
Using a stub geocoder on CI makes perfect sense. As a follow up point:
So CI runs on our repo use the production API key? I don't mind per se. Some questions:
I don't have particularly strong feelings on this, but good for me to understand the answers to those questions. @edwh |



The symptom
Forked pull requests fail CI in a way that looks like the contributor broke everything: all 50 Playwright tests fail at
createGroup, and the job times out. #906 is the current example — 2 of 50 passing, on a diff that only removes unused component registrations.The cause
CircleCI doesn't pass project environment variables to jobs built from forked PRs, so
GOOGLE_API_CONSOLE_KEYis empty on those runs.The evidence is in the logs: on a
developrun the string "restarters" is masked 68 times (a project env var's value), while #906's log has no masked strings at all — nothing was injected.With no key,
Geocoder::geocode()returnsfalse,API\GroupControllerthrowsValidationExceptionongroups.geocode_failed, the create form 422s and never redirects to/edit/, andwaitForURL('**/edit/**')times out. Every test callscreateGroup, so every test fails, from the first one.Reproduced locally: blanking the key makes
geocode('London')returnfalse.The fix
A
StubGeocoderanswering from a fixed table, bound only whenGEOCODER_STUBis set — which CI sets only when there's no key, so runs on this repo still exercise the real geocoder, and production can't reach it.It keeps the
ForceGeocodeFailuresentinel failing, and falls back to London for an unlisted place so a new test fails on what it's actually testing.The alternative — turning on CircleCI's "pass secrets to forked PRs" — would hand the project's API keys to anyone who opens a fork PR. Not worth it for a geocoding lookup the tests don't need to be real.
Tests
6 unit tests: the stub is off unless deliberately enabled, it satisfies the
Geocodercontract, it answers the address the e2e suite actually types, it ignores case and whitespace, it falls back rather than failing, and it still fails for the sentinel. ExistingGeocoderTeststill passes.Note for #906
Because CircleCI builds the fork's head rather than a merge, #906 will keep failing until this lands and that branch merges
develop.🤖 Generated with Claude Code