Repository navigation
fix: drop the pre-1.0 /sdk and /__dagger.entrypoint.ts ignores on generate - #76
Merged
Merged
Conversation
grouville
self-requested a review
October 9, 2026 06:49
grouville
approved these changes
Oct 9, 2026
TomChv
force-pushed
the
fix/legacy-gitignore
branch
from
October 9, 2026 11:41
0a01b02 to
5b3aa6a
Compare
…erate A module written by a v0.21 engine carries a .gitignore naming sdk/ and __dagger.entrypoint.ts, because its runtime regenerated both on every call. A 1.0 module commits them, the trusted runtime does no codegen, and source loading honours .gitignore before the runtime sees the tree, so the two lines hide the very files the module requires: `committed generated file "sdk/client.gen.ts" is missing`, with the file on disk. dagger/dagger#13720 taught `dagger setup` to remove exactly those lines, but it learns them by running the legacy SDK's codegen, which an SDK-module provider like this one does not implement, so for a module this SDK converts the engine removes nothing — and this SDK's own dagger.json conversion never touched the file either (SDK Main-Engine Test Run, 2026-10-07 — issue #25, case G14). generateScope now takes the `/sdk` (or `/sdk/`) and `/__dagger.entrypoint.ts` lines out of the module's .gitignore with the same semantics as #13720: only those exact root-anchored lines, every other line kept byte for byte, a removed line taking only its own terminator, the file written only when a line went, never created, and left in place when emptied. It runs on every generation under either loading path, because a manifest written by an earlier SDK version or by `dagger setup` has already lost the dagger.json that marks a migration, and before the first module load of the run, because a workspace-backed module source applies the .gitignore too and would hide the staged sdk/ from the self client's load. Three e2e checks cover it on the legacy-deps fixture pair: the lines go and the rest survives verbatim, a second generation leaves the file untouched (asserted on the changeset layer), and a module with no .gitignore or one naming no generated file is not written. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
force-pushed
the
fix/legacy-gitignore
branch
from
October 9, 2026 14:17
5b3aa6a to
0108a91
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.
Problem
(SDK Main-Engine Test Run, 2026-10-07 — issue #25, case G14.)
This PR fixes half (1). Half (2) is out of scope — see Not covered.
Root cause
A module written by a pre-1.0 engine carries a
.gitignorenaming the files itsruntime used to regenerate on every call. The v0.21 TypeScript SDK declared
sdk/**generated andsdk,**/node_modules/**,**/.pnpm-store/**ignorable(
[email protected] sdk/typescript/runtime/main.go:147-154), the engine added.env(core/codegen.go:134), and then appended one root-anchored line perentry (
core/schema/modulesource.go, thewriteGitignoreblock at:2479). Soa v0.21 module's
.gitignorereads exactly — see.dagger/modules/e2e/fixtures/generate-legacy-deps/app/.gitignore:Under 1.0 those generated files are committed: the trusted runtime does no
codegen. Module source loading applies
.gitignorebefore the runtime sees thetree (
core/schema/modulesource.go:1269,Gitignore: src.Workspace.Self() != nil || …), so/sdkhidessdk/client.gen.tsand the module cannot load eventhough the file is on disk — the loop described in dagger/dagger#13717.
dagger/dagger#13720 taught
dagger setupto remove exactly the ignore lines thatname generated paths (
core/schema/workspace_migrate.go:245learns them,:825removeWorkspaceMigrationGitignoreEntriesapplies them). It learns themby running the legacy SDK's
Codegen, which an SDK-module provider like this onedoes not implement, so it bails at
:294(ErrSDKCodegenNotImplemented) andreturns nothing for a TypeScript module. And this SDK's own conversion
(
typescript-sdk.dang,withModuleManifest'shasJSONbranch) never touched.gitignoreat all. Hence:workspace migratedrops/sdk, the SDK's ownconversion did not.
Fix
withoutLegacyIgnores(typescript-sdk.dang:454), applied fromgenerateScopeat
:249:<module source dir>/.gitignore(moduleFiles'sourcePath, thedirectory the generated files land in), only if the file exists — never creates
one;
/sdk(/sdk/accepted) and/__dagger.entrypoint.ts. Every other line survives byte for byte — thenode_modules,.pnpm-storeand.envrules, comments, blank lines — and aremoved line takes only its own terminator (
\rincluded);bytes still lands in the changeset layer and is reported as a whole-file
addition on the next run (see
writeChanged's docstring at:1654);Asserts.untouchedis what proves it did not;v0.21 always wrote more than these two lines, so an emptied file is one the
user trimmed by hand, and removing it is a bigger surprise than taking two
lines out.
Two deliberate choices beyond the brief:
It runs for both layouts, not only
[runtime]. The lines are stale undereither, an entrypoint module has no
sdk/for/sdkto hide anyway, and amodule moved back onto a
[runtime]would be unloadable again with no migrationleft to repair it.
It runs on every generation, not only in the
hasJSONmigration branch, andbefore the first module load of the run rather than on the way out. A manifest
that
dagger setupor an earlier version of this SDK migrated has already lostthe
dagger.jsonthat marks a module as migrating, so its nextgenerateis theonly chance to repair it. Early, because a workspace-backed module source applies
the module's
.gitignoretoo: left in place,/sdkhides the stagedsdk/fromthe self client's load inside the same run, and the module silently generates
without its own client (visible in the repro below — before the fix the module
got no
sdk/legacydep.gen.ts).README.mdgains one sentence in the migration paragraph.Verification
Engine:
dagger --x-release=55e112468d5b08e3a8746e7e74a4dc38898cf07a(v1.0.0-beta.17 · 55e11246),
DAGGER_LEAVE_OLD_ENGINE=1, on the legacy[runtime]layout the matrix row was observed on (Gen.scopedefaults tolegacyRuntime: true; the manual repro pins the scope setting explicitly). Thedefault was not changed.
New checks, before the fix
Same checks, SDK without the fix:
The other two are green before the fix by construction: nothing wrote
.gitignoreat all, so "already clean is not rewritten" and "a module withoutone gets none" were trivially true. They are the regression guards for the
fix's write only when a line went and never create clauses, and they would
fail on a version of this fix that rewrote the file unconditionally.
New checks, after the fix
Run:
dagger check -m .dagger/modules/e2e generate/generate-cleans-legacy-ignore-check generate/generate-legacy-ignore-settles-check generate/generate-leaves-other-ignores-check generate/generate-migrates-legacy-config-check generate/generate-idempotent-check generate/generate-dependency-checkin a scratch copy of this branch using.dagger/modules/engine-e2e/workspace.tomlas itsdagger.toml.The rest of the suite (68 checks, including
runtimes:*) is being run on thisbranch by the coordinator, against the baseline it recorded on unmodified
main:67/68 green, the one red being
packager/library-bindings/stale, which isexpected on an engine newer than the committed library bindings and untouched
here.
Manual repro
A workspace with this SDK vendored,
dagger module install, andfixtures/generate-legacy-deps/depcopied in as a scope(
is-module = true,name = "legacydep",settings.legacyRuntime = true) whose.gitignoreis exactly what v0.21 wrote. Thendagger generate -y, commit,dagger -m legacy call value.Before — the two lines survive, git tracks nothing generated, the call fails:
After — the two lines are gone, the other three are untouched, the generated
tree is committable, and the call runs:
legacy/sdk/legacydep.gen.tsappearing only in the second run is theself-client half of the same bug: before the fix the module's own
.gitignorehid the staged
sdk/from the self client's load during generation.Not covered / follow-ups
recorded without a
nameis renamed after its directory, solegacy-typescriptbecomes<dir>-dev. That is the engine's inference(
core/schema/workspace_sdk_module.goresolveSDKModuleName→workspace.InferSDKModuleName), not something this SDK can decide; thecoordinator reports it separately.
(
workspace_migrate.go:294bails onErrSDKCodegenNotImplemented), so adagger setupof a TypeScript module leaves the lines for the firstdagger generateto remove. Repairing it engine-side — e.g. letting aprovider declare its stale ignore lines — would also cover SDKs that have no
equivalent of this step.