fix(data-warehouse): shrink new-source wizard payload and gzip it - #70804
Merged
Conversation
The wizard endpoint shipped the docs-only documented-tables catalog (43% of a 1.2 MB response) to a frontend that never reads it, and the path was not on the scoped gzip allowlist so it went out uncompressed. Drop the tables catalog from the wizard response, memoize the deploy-static catalog build, and allowlist the path for gzip: 1.22 MB -> 86 KB over the wire. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Reviews (1): Last reviewed commit: "fix(data-warehouse): shrink new-source w..." | Re-trigger Greptile |
Gilbert09
approved these changes
Jul 14, 2026
The allowlist regex only accepted numeric team ids, so requests via /api/environments/@current/... shipped uncompressed. The environments rewrite middleware carries @current over unchanged, so the digits-only pattern never matched those either way. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
danielcarletti
enabled auto-merge (squash)
July 14, 2026 17:19
Contributor
🤖 CI report
|
| File | Patch | Uncovered changed lines |
|---|---|---|
products/data_warehouse/backend/presentation/views/public_source_configs.py |
66.7% | 39–41 |
🤖 Agents: add a test covering the lines above, or note why under "How did you test this code?". Machine-readable gap list: the patch-coverage artifact on this run (gh run download 29353135880 -n patch-coverage), or the coverage-data block at the end of this comment.
Per-product line coverage (touched products)
| Product | Coverage | Lines |
|---|---|---|
platform_features |
██░░░░░░░░░░░░░░░░░░ 12.1% |
7 / 58 |
batch_exports |
████████░░░░░░░░░░░░ 39.7% |
8,416 / 21,220 |
demo |
███████████░░░░░░░░░ 56.2% |
1,497 / 2,663 |
warehouse_sources_queue |
████████████░░░░░░░░ 59.2% |
148 / 250 |
tasks |
█████████████░░░░░░░ 67.2% |
25,262 / 37,571 |
data_tools |
██████████████░░░░░░ 70.0% |
63 / 90 |
ai_gateway |
███████████████░░░░░ 75.0% |
9 / 12 |
data_modeling |
████████████████░░░░ 78.4% |
4,696 / 5,987 |
signals |
████████████████░░░░ 78.5% |
18,105 / 23,059 |
cdp |
████████████████░░░░ 80.7% |
3,118 / 3,864 |
wizard |
████████████████░░░░ 82.5% |
772 / 936 |
cohorts |
█████████████████░░░ 82.9% |
3,048 / 3,675 |
notebooks |
█████████████████░░░ 83.8% |
6,086 / 7,259 |
agent_platform |
█████████████████░░░ 84.1% |
3,095 / 3,678 |
actions |
█████████████████░░░ 86.6% |
717 / 828 |
product_tours |
█████████████████░░░ 87.5% |
1,266 / 1,447 |
exports |
██████████████████░░ 88.3% |
6,857 / 7,763 |
visual_review |
██████████████████░░ 88.5% |
5,565 / 6,287 |
business_knowledge |
██████████████████░░ 88.5% |
4,400 / 4,969 |
conversations |
██████████████████░░ 88.9% |
15,924 / 17,921 |
mcp_analytics |
██████████████████░░ 89.1% |
2,485 / 2,790 |
dashboards |
██████████████████░░ 89.1% |
5,648 / 6,337 |
engineering_analytics |
██████████████████░░ 89.4% |
4,560 / 5,100 |
error_tracking |
██████████████████░░ 89.5% |
9,613 / 10,737 |
streamlit_apps |
██████████████████░░ 90.4% |
2,499 / 2,764 |
slack_app |
██████████████████░░ 90.6% |
9,460 / 10,444 |
links |
██████████████████░░ 90.6% |
183 / 202 |
marketing_analytics |
██████████████████░░ 90.7% |
11,476 / 12,646 |
alerts |
██████████████████░░ 90.9% |
3,416 / 3,760 |
product_analytics |
██████████████████░░ 91.1% |
5,507 / 6,048 |
data_warehouse |
██████████████████░░ 91.9% |
17,694 / 19,263 |
managed_migrations |
██████████████████░░ 91.9% |
908 / 988 |
workflows |
██████████████████░░ 92.0% |
4,795 / 5,210 |
mcp_store |
██████████████████░░ 92.1% |
3,665 / 3,981 |
web_analytics |
███████████████████░ 92.7% |
13,702 / 14,787 |
notifications |
███████████████████░ 92.7% |
1,026 / 1,107 |
ai_observability |
███████████████████░ 92.7% |
14,670 / 15,822 |
surveys |
███████████████████░ 92.9% |
5,660 / 6,094 |
posthog_ai |
███████████████████░ 93.2% |
1,311 / 1,407 |
tracing |
███████████████████░ 93.2% |
2,423 / 2,599 |
approvals |
███████████████████░ 93.3% |
3,395 / 3,640 |
reminders |
███████████████████░ 93.4% |
468 / 501 |
early_access_features |
███████████████████░ 93.8% |
848 / 904 |
legal_documents |
███████████████████░ 94.1% |
1,568 / 1,667 |
endpoints |
███████████████████░ 94.1% |
8,606 / 9,143 |
skills |
███████████████████░ 94.4% |
2,827 / 2,995 |
revenue_analytics |
███████████████████░ 94.4% |
3,586 / 3,797 |
messaging |
███████████████████░ 94.5% |
2,530 / 2,677 |
review_hog |
███████████████████░ 94.5% |
6,429 / 6,802 |
logs |
███████████████████░ 95.3% |
9,476 / 9,942 |
growth |
███████████████████░ 95.5% |
2,734 / 2,864 |
experiments |
███████████████████░ 95.6% |
24,045 / 25,152 |
replay_vision |
███████████████████░ 95.7% |
13,151 / 13,745 |
feature_flags |
███████████████████░ 96.0% |
14,600 / 15,203 |
warehouse_sources |
███████████████████░ 96.1% |
214,534 / 223,219 |
annotations |
███████████████████░ 96.2% |
732 / 761 |
user_interviews |
███████████████████░ 96.4% |
2,242 / 2,325 |
access_control |
███████████████████░ 96.8% |
849 / 877 |
data_catalog |
███████████████████░ 97.2% |
1,642 / 1,689 |
customer_analytics |
███████████████████░ 97.3% |
7,396 / 7,600 |
analytics_platform |
████████████████████ 98.2% |
2,098 / 2,137 |
metrics |
████████████████████ 98.3% |
2,363 / 2,405 |
live_debugger |
████████████████████ 99.2% |
613 / 618 |
field_notes |
████████████████████ 99.4% |
158 / 159 |
Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first.
Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.
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.
Problem
The new-source wizard page (
/pipeline/new/source) blocks onGET /api/environments/:id/external_data_sources/wizard/, which returned 1.22 MB of uncompressed JSON describing all 761 registered sources. Two compounding issues:tableskey is the credential-free documented-table catalog built for the posthog.com docs build (served by the public/api/public_source_configs/endpoint). Nothing on the app path reads it: the frontendSourceConfigtype has notablesfield, and the MCP tool's response projection (pickResponseFieldsinservices/mcp) only passes throughname,caption,docsUrl,featured,unreleasedSource, andfields.ScopedGZipMiddleware), and this path wasn't on it.Server CPU was not the bottleneck (catalog build is ~35 ms warm), transfer was.
Changes
build_source_configs()gains a keyword-onlyinclude_tablesflag and is memoized withfunctools.cache(the catalog is deploy-static, it only changes when source code ships)include_tables=False; the public docs endpoint is unchanged and keepstablesGZIP_RESPONSE_ALLOW_LIST. BREACH-safe: the response reflects no user input and contains no secretstables, and that the wizard response carries notableskeyNo frontend change needed, and the OpenAPI spec is unchanged (
tableswas never part of theSourceConfigschema, it was bolted onto the dict).Estimated impact
Pages that fetch this endpoint (the new-source wizard, the source connect scene, and the source configuration tab) get roughly 14k loads per month across US and EU Cloud combined. That works out to about 16.7 GB/month of uncompressed transfer before, ~1.2 GB/month after, so ~15.5 GB/month saved (93%). At typical cloud egress rates that's only a couple of dollars a month, so the dollar savings are negligible. The real win is page load time (1.2 MB of JSON on a slow connection is seconds of blocking spinner) plus a small per-request CPU saving on the web workers.
Is the MCP tool affected?
No. The generated
external-data-sources-wizardMCP tool fetches this endpoint and then applies an include-list projection before returning anything to the model.tableswas fetched over the internal network and immediately discarded, so the tool's output is byte-identical after this change. The tool also declares its response asunknown(no zod validation of the response body), so removing a key cannot break parsing. Side benefit: the MCP service now downloads 688 KB instead of 1.22 MB for unfiltered calls.How did you test this code?
Automated (run locally, all green):
products/data_warehouse/backend/tests/api/test_public_source_configs.py(7 passed), including the updated drift test — it now catches both regressions this change creates room for: the two endpoints drifting on shared fields, and someone re-addingtablesto the wizard response and doubling the payloadproducts/data_warehouse/backend/tests/api/test_external_data_source.py -k wizard(15 passed)posthog/test/test_gzip_middleware.py— 2 passed, 2 pre-existing failures that fail identically on a clean tree (local env can't render the home page), unrelated to this change/api/environments/2/external_data_sources/wizard/and/api/projects/2/external_data_sources/wizardand nothing else on that routerI (Claude) did not manually test the page in a browser.
Automatic notifications
Docs update
No docs reference the wizard endpoint payload shape; the public docs endpoint that posthog.com consumes is unchanged.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
/improving-drf-endpoints,/writing-tests.SourceConfigtype (notablesfield, no.tablesreads in app code) and the generated MCP tool (include-list projection drops it).availableSourcesLogic, then multiplying by measured payload sizes.🤖 Generated with Claude Code