Skip to content

fix: stop CI failing on forked PRs for want of a geocoding key - #908

Open
edwh wants to merge 1 commit into
developfrom
fix/e2e-geocoder-without-api-key
Open

fix: stop CI failing on forked PRs for want of a geocoding key#908
edwh wants to merge 1 commit into
developfrom
fix/e2e-geocoder-without-api-key

Conversation

@edwh

@edwh edwh commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

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_KEY is empty on those runs.

The evidence is in the logs: on a develop run 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() returns false, API\GroupController throws ValidationException on groups.geocode_failed, the create form 422s and never redirects to /edit/, and waitForURL('**/edit/**') times out. Every test calls createGroup, so every test fails, from the first one.

Reproduced locally: blanking the key makes geocode('London') return false.

The fix

A StubGeocoder answering from a fixed table, bound only when GEOCODER_STUB is 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 ForceGeocodeFailure sentinel 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 Geocoder contract, 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. Existing GeocoderTest still 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

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>
@edwh
edwh force-pushed the fix/e2e-geocoder-without-api-key branch 2 times, most recently from 613788a to 1ca8e77 Compare September 8, 2026 16:17
@edwh

edwh commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

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 GEOCODER_STUB=true for the e2e run only (after PHPUnit, so the unit test asserting the stub is off by default still saw a truthful environment). The run confirmed both halves:

stub step -> App\Helpers\StubGeocoder
Run main Playwright tests -> success

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).

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

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