fix(ci): reformat generated ProcessEnv union to eliminate recurring merge conflicts#3871
Merged
Merged
Conversation
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3871 +/- ##
=======================================
Coverage 93.57% 93.57%
=======================================
Files 340 340
Lines 33508 33508
Branches 12255 12255
=======================================
Hits 31355 31355
Misses 1528 1528
Partials 625 625 🚀 New features to boost your workflow:
|
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 Gittensory is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
JSONbored
force-pushed
the
fix/cf-typegen-processenv-diff-friendly
branch
from
July 7, 2026 01:24
673a41c to
bde197e
Compare
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | ff442f9 | Commit Preview URL Branch Preview URL |
Jul 07 2026, 01:38 AM |
JSONbored
force-pushed
the
fix/cf-typegen-processenv-diff-friendly
branch
from
July 7, 2026 02:10
812e63c to
f945798
Compare
…erge conflicts worker-configuration.d.ts (generated by `wrangler types`) packs every declared env var into one long single-line `Pick<Cloudflare.Env, "A" | "B" | ...>>` union in the ProcessEnv interface. Two independent PRs that each add a different new var to wrangler.jsonc's `vars` both regenerate that same line with their own insertion; git's line-based 3-way merge sees "the same line changed differently in both branches" and reports a real conflict, even though the two additions are logically unrelated. This hit several same-day PRs in a row during the Wraps `wrangler types` in scripts/gen-cf-typegen.mjs, which still regenerates via the real CLI (so it can never drift from wrangler's own output) but reformats that one union onto one sorted entry per line, same as every other interface body in the file already is. Two PRs adding different vars now land on different, non-adjacent lines and merge cleanly. cf-typegen:check is rebuilt on the same script (a temp-path regeneration compared against the committed file) rather than wrangler's own --check flag, which can't see the reformatting step. Includes a regression test that reproduces the original conflict via a real `git merge-file` before the fix and confirms it resolves cleanly after.
JSONbored
force-pushed
the
fix/cf-typegen-processenv-diff-friendly
branch
from
July 7, 2026 02:33
f945798 to
0a4b8cb
Compare
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
worker-configuration.d.ts— even though the underlying feature changes didn't overlap at all. Root cause:wrangler typespacks every declared env var into ONE long single-linePick<Cloudflare.Env, "A" | "B" | ...>>union in the generatedProcessEnvinterface. Two independent PRs that each add a different new var towrangler.jsonc'svarsboth regenerate that same line with their own insertion; git's line-based 3-way merge sees "the same line changed differently in both branches" and reports a real conflict, even though the two additions are logically unrelated. Everything else in the file (the plain per-line__BaseEnv_Envinterface body,wrangler.jsonc,src/env.d.ts, etc.) already merges cleanly — this one packed-union line was the sole recurring offender.scripts/gen-cf-typegen.mjsstill regenerates via the realwrangler typesCLI (so the committed file can never silently drift from wrangler's own output), then reformats just that one union onto one sorted entry per line — the same shape every other interface body in this file already has. Two PRs adding different vars now land on different, non-adjacent lines and merge cleanly.cf-typegen:checkis rebuilt on the same script (regenerates to a temp path, applies the identical reformatting, and string-compares against the committed file) rather than wrangler's own--checkflag, which has no way to see the extra reformatting step and would otherwise always report a false mismatch.test/unit/ci-cf-typegen.test.ts) that reproduces the original conflict via a realgit merge-fileinvocation on the raw single-line format (confirmed it conflicts) and confirms the reformatted version of the exact same two additions merges cleanly with zero conflict markers.I also rebased and pushed fixes for the two already-open PRs that hit this (#3835, #3840) — both are
MERGEABLEagain now.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateAll run via
npm run test:ci(full local gate, green) plus a standalonenpm audit --audit-level=moderate(0 vulnerabilities).scripts/**is Codecov-exempt (notsrc/**), but I verifiedcf-typegen/cf-typegen:checkboth round-trip correctly by hand: rancf-typegen, confirmedcf-typegen:checkreports clean; temporarily added a throwaway var towrangler.jsoncwithout regenerating and confirmedcf-typegen:checkcorrectly fails (exit 1) before reverting. Also updated the existingtest/unit/ci-cf-typegen-check.test.tsstructural guard (added in #2557) to assert the new script invocation instead of the literal oldwrangler types --checkstring — its CI-wiring/ordering assertions were untouched and still pass.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails.Build-tooling-only change: no auth/CORS/session surface, no interactive app UI, no behavioral change to the deployed Worker (the generated types are semantically identical, only reformatted).
UI Evidence
N/A — no app UI surface changed; this only affects a generated TypeScript declaration file's formatting.