Skip to content

Restore Cloud Run metadata gzip compression#3711

Merged
anth-volk merged 4 commits into
masterfrom
codex/restore-cloud-run-gzip
Jun 29, 2026
Merged

Restore Cloud Run metadata gzip compression#3711
anth-volk merged 4 commits into
masterfrom
codex/restore-cloud-run-gzip

Conversation

@anth-volk

Copy link
Copy Markdown
Collaborator

Fixes #3710

Summary

  • Restore standard ASGI gzip compression so large legacy Flask responses, including /us/metadata, are transported compressed without changing the JSON payload shape.
  • Add ASGI factory coverage showing large Flask fallback responses use HTTP gzip while callers still receive the normal decoded body.
  • Force unit tests onto the legacy SQLite path before importing the SQL module, with a note that the SQL layer needs broader refactoring in a later migration stage.

Why

The Stage 3 Cloud Run staging integration run failed because /us/metadata exceeded Cloud Run's uncompressed response-size limit. The app logged 200 OK, but Cloud Run returned 500 with Response size was too large.

This keeps the existing endpoint contract intact: callers like policyengine-app-v2 can continue using normal fetch(...).json() with no custom decompression or framing.

Validation

  • uv run pytest tests/unit/test_asgi_factory.py::test_large_flask_fallback_response_supports_http_gzip
  • uv run ruff check tests/unit/conftest.py policyengine_api/asgi_factory.py tests/unit/test_asgi_factory.py
  • uv run ruff format --check tests/unit/conftest.py policyengine_api/asgi_factory.py tests/unit/test_asgi_factory.py
  • Manual Node fetch check against the patched ASGI wrapper confirmed fetch(...).json() receives decoded JSON while the transport response uses Content-Encoding: gzip.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.81%. Comparing base (0fc959c) to head (ab8156d).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3711      +/-   ##
==========================================
- Coverage   78.87%   78.81%   -0.06%     
==========================================
  Files          71       71              
  Lines        4318     4320       +2     
  Branches      804      804              
==========================================
- Hits         3406     3405       -1     
- Misses        698      702       +4     
+ Partials      214      213       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anth-volk anth-volk marked this pull request as ready for review June 29, 2026 21:41
@anth-volk anth-volk merged commit 193167b into master Jun 29, 2026
8 of 9 checks passed
@anth-volk anth-volk deleted the codex/restore-cloud-run-gzip branch June 29, 2026 21:42
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.

Restore gzip compression for Cloud Run metadata responses

1 participant