Skip to content

fix: refuse to move a module whose source is a subdirectory onto an entrypoint - #85

Merged
TomChv merged 1 commit into
mainfrom
fix/entrypoint-source-subpath
Oct 12, 2026
Merged

TomChv merged 1 commit into
mainfrom
fix/entrypoint-source-subpath

Conversation

@TomChv

@TomChv TomChv commented Oct 9, 2026

Copy link
Copy Markdown
Member

Follow-up to #73, found while Tom tested #78 on a real migrated module.

Problem

dagger generate dies on a module whose manifest aims source somewhere other than the scope:

! dag://?generator=dagger-typescript-sdk/generate:
  stat typescript/migrations/dag-dep-compat/src: no such file or directory

Since #73 made the entrypoint the default, typescript-sdk.dang:257 hard-set the source directory to the scope:

let source = if (legacyRuntime == false) { scope } else { moduleSourcePath(configured, scope) }

so a module with source = "hello-world" has generation look for <scope>/src, which is not there.

Bisected: v1.0.1 and 94a66a4 (#73's parent) pass; 8a7c580 onward fail with a byte-identical message. git log -L blames the line to #73. The unmigrated dagger.json form fails the same way, so the blast radius is any pre-1.0 module whose config aims source at a subdirectory — the layout dagger init wrote inside an existing project ("source": ".dagger"). Migration preserves source, so the first generate after migrating is where people land.

Fix

Hard-setting the source is deliberate — an entrypoint manifest has no source field to record anywhere else, so the module root is the only answer it can give. What was missing is saying so instead of inventing a path:

! module "hello-world" keeps its source in typescript/migrations/dag-dep-compat/hello-world,
  and an entrypoint manifest has no `source` field to record that: set legacyRuntime = true
  in the scope's settings in dagger.toml to keep its [runtime] layout, or move its files to
  typescript/migrations/dag-dep-compat

entrypointSourcePath reads the config the scope arrived with (seeded, not configured) — withEntrypointManifest has already dropped source by then, which is also why a second generation of an already-flipped module resolves "." and passes.

This refuses; it does not support. Supporting a subdirectory source under an entrypoint needs somewhere to persist it across generations, and the manifest's source is gone by design (withoutLegacyFields). The one viable carrier is the [entrypoint] source itself — writing "./hello-world/entrypoint" and reading the module path back off it; --module-path is already workspace-root-relative (entrypoint_dang.go), so the generated recipe could address a subdirectory today. That is a design change, not a bug fix, so it is deliberately not here.

Also: the README named a setting that does nothing

README.md:115 said to set legacy-runtime in the scope's settings. The engine silently ignores an unknown settings key — no error, no warning — so the kebab-case form reports success and leaves the module on the entrypoint path. The field is legacyRuntime, as the settings table five lines earlier says. That silent drop is engine-side and worth its own report: every scope-settings typo is invisible.

Verification

  • generate:generate-refuses-entrypoint-source-subpath-check — new, and it goes red without the fix (generating an entrypoint for a module whose source is elsewhere should be refused), green with it. It reuses the existing parent-source fixture, whose manifest already carries source = "../../../ci", so no new fixture.
  • generate:generate-split-source-runtime-check and manifest:split-source-client-check — the two existing checks over that fixture — still green, so the [runtime] path is unaffected.
  • Both Dang modules parse at v1.0.0-beta.16.
  • The original repro: refusal naming the setting instead of stat .../src; with legacyRuntime = true it generates, and a second run reports no changes.

…ntrypoint

Since #73 made the entrypoint the default, generateScope hard-sets an
entrypoint module's source directory to the scope, ignoring what the
manifest's `source` says. A module whose files live elsewhere — the layout
`dagger init` wrote inside an existing project, `"source": ".dagger"`, and
the one migration carries into dagger-module.toml — then generates against a
directory that is not there and dies on

    stat <scope>/src: no such file or directory

naming neither the source it ignored nor the setting that keeps the module's
own layout. Reported by Tom hitting it on a migrated playground module with
`source = "hello-world"`; bisected to 8a7c580 (#73), and the unmigrated
dagger.json form fails the same way.

Hard-setting the source is deliberate: an entrypoint manifest has no `source`
field to record anywhere else, so the module root is the only answer it can
give. What was missing is saying so. entrypointSourcePath reads the config the
scope arrived with and refuses when it points somewhere else, naming
`legacyRuntime = true` as the way to keep the `[runtime]` layout.

The read is off `seeded` rather than `configured` deliberately:
withEntrypointManifest has already dropped `source`, which is also why a
second generation of an already-flipped module resolves "." and passes.

README also told people to set `legacy-runtime` in the scope's settings. The
engine silently ignores an unknown settings key, so the kebab-case form
reports success and changes nothing; the field is `legacyRuntime`.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv force-pushed the fix/entrypoint-source-subpath branch from b28b9ba to 4f3abb5 Compare October 12, 2026 10:03
@TomChv
TomChv merged commit 5e3cca6 into main Oct 12, 2026
5 checks passed
TomChv added a commit that referenced this pull request Oct 13, 2026
generateScope passed `hasToml` to withEntrypointManifest where the
`[runtime]` path passes `hasJSON`, so a scope arriving with only a pre-1.0
dagger.json built a fresh, empty entrypoint manifest and never read the
file — while `generate(legacyJson: false)` deleted it. Its
`[[dependencies]]`, `include`, `toolchains`, `blueprint` and even a foreign
`"sdk"` went with it: exit 0, no message.

An entrypoint manifest has no table for any of them, so there is nothing to
carry them into. Refuse instead, the way #85 already does for a `source`
subpath: read the config the scope arrived with, and name
`legacyRuntime = true` as the layout that can hold them. A dagger.json
declaring none of them still migrates onto the entrypoint.

Fixes #88

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit that referenced this pull request Oct 13, 2026
generateScope passed `hasToml` to withEntrypointManifest where the
`[runtime]` path passes `hasJSON`, so a scope arriving with only a pre-1.0
dagger.json built a fresh, empty entrypoint manifest and never read the
file — while `generate(legacyJson: false)` deleted it. Its
`[[dependencies]]`, `include`, `toolchains`, `blueprint` and even a foreign
`"sdk"` went with it: exit 0, no message.

An entrypoint manifest has no table for any of them, so there is nothing to
carry them into. Refuse instead, the way #85 already does for a `source`
subpath: read the config the scope arrived with, and name
`legacyRuntime = true` as the layout that can hold them. A dagger.json
declaring none of them still migrates onto the entrypoint.

Fixes #88

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit that referenced this pull request Oct 14, 2026
generateScope passed `hasToml` to withEntrypointManifest where the
`[runtime]` path passes `hasJSON`, so a scope arriving with only a pre-1.0
dagger.json built a fresh, empty entrypoint manifest and never read the
file — while `generate(legacyJson: false)` deleted it. Its
`[[dependencies]]`, `include`, `toolchains`, `blueprint` and even a foreign
`"sdk"` went with it: exit 0, no message.

An entrypoint manifest has no table for any of them, so there is nothing to
carry them into. Refuse instead, the way #85 already does for a `source`
subpath: read the config the scope arrived with, and name
`legacyRuntime = true` as the layout that can hold them. A dagger.json
declaring none of them still migrates onto the entrypoint.

Fixes #88

Signed-off-by: Tom Chauveau <[email protected]>
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.

1 participant