Skip to content

Resolve modules through dagger-module.toml#7

Closed
eunomie wants to merge 1 commit into
mainfrom
dang-sdk-mod-resolve-workspace-modules
Closed

Resolve modules through dagger-module.toml#7
eunomie wants to merge 1 commit into
mainfrom
dang-sdk-mod-resolve-workspace-modules

Conversation

@eunomie

@eunomie eunomie commented Jul 16, 2026

Copy link
Copy Markdown
Member

The dang-sdk half of dagger/go-sdk#10 — the same bug, in the same shape.

The bug

mod() resolved a workspace path to its owning module with a single find-up for dagger.json. Modules carrying a dagger-module.toml instead have no dagger.json to find, so every lookup against them failed with no Dagger module found containing path. Once dagger/dagger#13651 lands, that is every workspace-managed module.

Verified: against a migrated module, mod reports no Dagger module found containing path: toml-app before this change and resolves after it.

The fix

Find up both dagger-module.toml and dagger.json and keep the closest match, checking [runtime] source = "dang" for the former and leaving the existing dagger.json check untouched.

Comparing both in one pass — rather than trying dagger-module.toml first and falling back — is what keeps find-up's closest-wins semantics: an ancestor's dagger-module.toml must not shadow a legacy module that sits deeper, which is the shape a partially migrated workspace has.

A lookup against another SDK's module now names the runtime that owns it — does not use the Dang SDK: <path> (runtime source: go) — instead of reporting no module at all.

findUp: false is untouched and still bypasses resolution.

Scope: no as-sdk tier here

dagger/go-sdk#10 has a third, higher-precedence tier reading the workspace's [[modules.<sdk>.as-sdk.modules]] entries. It is deliberately absent here: this module declares engineVersion = "v0.20.8", and currentModule.asSDK does not exist at that version — referencing it is a compile error, not a catchable one. This repo also has no dagger.toml and no as-sdk config, and generateAll still discovers modules by scanning the filesystem.

Adding that tier means migrating this SDK to the 1.0 schema first (engine version bump, .{x}.{{x}}), which is its own change. The two-tier resolver here fixes the reported bug on the current schema.

Verification

There is no e2e module in this repo, so this was checked against a synthetic workspace: a migrated dagger-module.toml module resolves; legacy find-up from a nested path resolves; a go-owned module is rejected naming go; a partially migrated workspace resolves to the deeper legacy module rather than the migrated ancestor; a legacy non-dang module is rejected; and findUp: false with /x/ still returns x/. Worth noting that none of that is committed — this repo has no test harness to put it in.

mod() resolved a workspace path to its owning module with a single
find-up for dagger.json. Modules that carry a dagger-module.toml
instead have no dagger.json to find, so every lookup against them
failed with "no Dagger module found containing path".

Find up both markers and keep the closest match. Comparing them in one
pass rather than trying dagger-module.toml first keeps find-up's
closest-wins semantics: an ancestor's dagger-module.toml must not shadow
a legacy module that sits deeper, which is the shape a partially
migrated workspace has.

Report the runtime that owns a module when it is not dang, so a lookup
against another SDK's module says so instead of reporting no module.

Signed-off-by: Yves Brissaud <yves@dagger.io>
@eunomie
eunomie marked this pull request as draft July 16, 2026 11:22
@vito vito self-assigned this Jul 16, 2026
@grouville
grouville self-requested a review July 20, 2026 17:24
@TomChv

TomChv commented Jul 22, 2026

Copy link
Copy Markdown
Member

Fixed by #8 already

@TomChv TomChv closed this Jul 22, 2026
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.

3 participants