Skip to content

Legacy .gitignore rules break trusted runtimes after module migration #13717

Closed

Description

@grouville

What is happening

I hit an awkward migration edge case while working on the trusted/no-codegen runtime path.

The new model expects generated SDK files to be committed. But a module created with the previous behavior may still have those files in .gitignore. When we load a local module, we apply .gitignore before giving the source to the SDK runtime. The files are on disk, but the trusted runtime cannot see them and tells the user to run dagger generate again.

The reason this shows up now is that we changed what generated files mean.

With runtime codegen, generated files were disposable. The SDK recreated them whenever the module was loaded, so ignoring them was expected and useful. The trusted runtime deliberately does the opposite: it does not regenerate anything. It expects the files produced by dagger generate to be part of the module source.

Both behaviors make sense on their own. The bug appears when dagger setup moves a module from the first model to the second and keeps the .gitignore entries written for the first one.

Today, the migration step in dagger setup writes the new dagger.toml / dagger-module.toml configuration and resolves the migrated SDK references, but it does not update .gitignore. (dagger migrate was the name of this flow on earlier workspace branches; it has since been folded into dagger setup.)

At that point the module is stuck in this loop:

dagger setup migrates the module but leaves the old ignore rules
        ↓
dagger generate writes the files
        ↓
the files exist in the project
        ↓
local source loading applies the old .gitignore rules
        ↓
the trusted runtime receives a context without the files
        ↓
Dagger says to run dagger generate

Running dagger generate again cannot repair this because generation is not the part that failed.

automaticGitignore = false is easy to misunderstand here. It only means that Dagger should stop editing .gitignore from now on. It does not remove an entry Dagger added in the past, and it does not tell the source loader to disregard that entry. That is why a migrated module can have the new setting and still fail.

Why we did not see it earlier

The existing trusted-runtime tests cover the two obvious states: generated files are present and the module works, or they are absent and the runtime returns a useful error.

The migration introduces a third state: the files are present on the host but absent from the Directory passed to the runtime. Looking only at the filesystem or only at the runtime validation makes each side appear correct. The filtering happens between them.

Fresh modules are also less likely to expose this because automaticGitignore = false prevents the conflicting entries from being added in the first place. The problematic state mainly comes from modules carrying forward .gitignore entries from the runtime-codegen behavior through dagger setup.

How far this reaches

This is shared by every SDK moving to committed generated files. The filenames differ, but the transition is the same:

SDK Trusted runtime status Legacy ignored paths What the repro reports missing
Go Landed in #13381 dagger.gen.go, internal/dagger, internal/telemetry dagger.gen.go
Python Current work in #13593 sdk/ sdk/pyproject.toml
TypeScript Upcoming work in #13621 sdk/, __dagger.entrypoint.ts sdk/client.gen.ts

The TypeScript result is tested with Tom's upcoming no-codegen implementation from #13621. cc @TomChv

I also checked dagger/sdk-sdk, dagger/polyfill, and the standalone SDK repositories. None of them changes the important boundary here: core filters the local module source before the language runtime receives it.

Reproduction

There is a cross-SDK integration reproduction here:

TestTrustedFilesRemainHiddenByLegacyGitignore

The test constructs the state immediately after migration: the module uses the new TOML/trusted-runtime configuration while the legacy ignore rules remain. It then generates each module normally and checks that the expected files really exist on disk. When the module is loaded, each runtime reports the generated file shown in the table above as missing.

The test does not currently invoke dagger setup itself. It keeps the reproduction focused by constructing its output state directly. The setup migration code has no .gitignore change, so this is the state the real command leaves behind. We should also add this case to the workspace migration coverage so the user-facing transition remains protected end to end.

This distinction matters: the test is not accepting any failed dagger call as a successful reproduction. Generation and the explicit on-disk checks must succeed first, and the later error must name the file hidden by source loading.

The focused integration test passes. It is a characterization test, so passing means it successfully observed those three specific failures.

Where this probably needs to be solved

By the time Go, Python, or TypeScript checks its generated files, those files have already been removed from the module context. Fixing the validation independently in each SDK would therefore be too late.

The question is what migration behavior we want in core. If trusted modules mean generated files are committed, migration needs to remove the exact legacy rules Dagger previously added while preserving the user's unrelated rules. If we still want generated files to remain ignored, source loading needs an explicit way to include them despite .gitignore.

I am not proposing one of those implementations in the SDK PRs yet. This issue is here to make the conflicting assumptions visible and let us choose the behavior once for every SDK.

Activity

  1. grouville commented on Jul 22, 2026

    @grouville
    MemberAuthor
  2. changed the title [-]Trusted runtimes can lose generated files to legacy .gitignore rules[/-] [+]Legacy .gitignore rules break trusted runtimes after module migration[/+] on Jul 22, 2026
  3. added this to the v1.0.0 milestone on Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions