Fix leaflux/fosberg test fixtures writing grid bands without index - #549
Merged
Conversation
…an serialize them
The leaflux and fosberg router-test `grid_factory` fixtures wrote source-grid
documents straight to Firestore with bands shaped `{"key": key}` — missing the
required `index` and `type` fields. Under pytest-xdist these fixtures are
briefly alive in the shared test owner's collection while, on another worker,
`TestListGridsWildcard` calls `list_grids_cross_domain`, which does
`Grid(**doc.to_dict())` over every one of the owner's grids with no error
handling. Serializing a fixture band with no `index` raised a Pydantic
ValidationError, so the wildcard-list endpoint returned 500 and the test failed
(assert 500 == 200).
The failure was flaky/latent before but became a consistent post-deploy CI
failure once more fixture grids were added. Build the fixtures' bands with an
enumerated `index` and `type: continuous` (every band these fixtures use is
continuous), so a concurrent cross-domain list serializes them cleanly.
Test-only; no product change. Verified against a live server serially and under
4-worker xdist (the parallel mode that triggered the flake).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #548. The post-deploy CI test job on
mainwent red on 4TestListGridsWildcard::test_wildcard_sorting_matrix_returns_200cases (assert 500 == 200) — not a product regression; the deploy itself succeeded and the feature is live.Root cause
The leaflux and fosberg router-test
grid_factoryfixtures write source-grid documents straight to Firestore with bands shaped[{"key": key}]— missing the requiredindexandtypefields onBand.CI runs the suite under pytest-xdist, and all tests share one test owner. While a leaflux/fosberg fixture grid is briefly alive on one worker,
TestListGridsWildcardon another worker callslist_grids_cross_domain, which serializes every one of the owner's grids viaGrid(**doc.to_dict())(router.py:228) with no error handling. A fixture band with noindexraises a PydanticValidationError→ the endpoint returns 500 → the wildcard test fails.Confirmed from prod logs: the failing
input_values are exactly these fixtures ({'key': 'leaf_area_density'},{'key': 'elevation'}, georef{'crs': 'EPSG:32611', 'shape': [6, 40, 40]}). The errors appeared only during the test session and stopped when the fixtures were torn down — the endpoint is healthy, and real API-created grids always have valid bands (this shape is only reachable by fixtures writing to Firestore directly).Fix
Build the fixtures' bands with an enumerated
indexandtype: "continuous"(every band these fixtures use —leaf_area_density,elevation,slope,aspect,irradiance.*— is continuous), so a concurrent cross-domain list serializes them cleanly:No product code changed. I deliberately left the list router alone — real data can't produce a bandless-
indexgrid, so the fault is the fixtures, not the endpoint.Verification
Ran leaflux + fosberg router tests and
TestListGridsWildcardagainst a live server — 81 passed serially and 81 passed under 4-worker xdist (the parallel mode that triggered the flake).ruff check/format --checkclean. Swept the suite for other fixtures with the same bandless-indexpattern — none remain.