Skip to content

fix(sdk/typescript): resolve referenced values in decorator arguments - #13292

Merged
TomChv merged 1 commit into
dagger:mainfrom
TomChv:fix/typescript-decorator-evaluation
Jun 1, 2026
Merged

TomChv merged 1 commit into
dagger:mainfrom
TomChv:fix/typescript-decorator-evaluation

Conversation

@TomChv

@TomChv TomChv commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

Problem

Decorator options were evaluated with eval() on the decorator's raw source text:

// ast.ts — getDecoratorArgument
case "object":
  return eval(`(${argument.getText()})`)

Because eval runs in an empty scope, any decorator option that referenced a module-level constant threw a ReferenceError. For example:

const IGNORE = ["foo", "bar", "baz"]

@func()
build(@argument({ ignore: IGNORE }) src: Directory): Directory { ... }

failed introspection, even though inlined literals ({ ignore: ["foo", "bar"] }) worked fine. This affected every option resolved as an object — @argument's defaultPath / ignore / defaultAddress and @func's alias / cache.

Fix

Replaced the eval with AST-based resolution that reuses the existing resolveParameterDefaultValue machinery (already used for parameter defaults), which knows how to follow identifiers, imports, and enum members back to their literal values. A new resolveDecoratorArgumentValue walks the object literal (handling key: value and shorthand { key }) and resolves each value through that resolver; the string-alias form @func("alias") falls through to the same path, preserving backward compatibility.

Tests

Added a decorators test case covering, with both inlined and referenced values, every decorator pattern the SDK exposes:

  • @argument → defaultPath (Directory/File), ignore, defaultPath+ignore, defaultAddress (Container)
  • @func → string alias, object alias, cache, alias+cache
  • @check / @generate / @up markers
  • @field and aliased-@func properties

Registered the case in scan.spec.ts. Full SDK test suite passes (97 passing) with no regressions.

A regression was introduced between v0.19.2 and v0.19.11 that break the
decorator resolution.
This commit fixes the that behaviour and add new tests
to ensure posterity.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv requested a review from a team as a code owner June 1, 2026 10:03
@TomChv
TomChv merged commit 8cc840f into dagger:main Jun 1, 2026
77 checks passed
shykes pushed a commit that referenced this pull request Jun 1, 2026
…#13292)

A regression was introduced between v0.19.2 and v0.19.11 that break the
decorator resolution.
This commit fixes the that behaviour and add new tests
to ensure posterity.

Signed-off-by: Tom Chauveau <[email protected]>
tiborvass added a commit that referenced this pull request Jun 5, 2026
…ash in fd0021b

This merge commit restores the history link between 1.0-beta branch and main.
It was lost with merge commit fd0021b which
squashed the branch e45e7e4

Git tree on #13327 before squash-merging into 1.0-beta:

```
* e45e7e4 Run dagger generate
*   a01677a Merge main into 1.0-beta
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| * 20b2554 Simplify function call return handling (#13319)
| * 316ca15 Fix snapshot owner lease attach/remove race (#13321)
| * 6cfdcb4 fix(layercopy): follow source symlinks when copying directory contents (#13326)
| * 16e85ca Container exists expand option (#13310)
| * 54f9811 chore: post-release during v0.21.4 (#13316)
| * de85595 ci: bump default engine version to v0.21.3 (#13315)
| * 81bb907 chore: prep for v0.21.4 (#13314)
| * 0fd148e Show root usage when dagger has no args
| * 219b696 Volatile vars (#13223)
| * fae340c fix(layercopy): materialize resolved parent dirs when writing through… (#13308)
| * b720144 bump dang (#13306)
| * 41a7910 fix(engine): lease parent layer content for tarball export (#13307)
| * b2d43ba fix(core): attach never-cached module function results (#13298)
| * 6a7b3a7 fix incorrect artifact caching issue when releasing  (#13285)
| * 2452472 fix(core/dotenv): accept `export`-prefixed lines in .env files (#13293)
| * 24b06e7 fix: allow empty setSecret name (#13304)
| * f7ea195 fix: handle 1Password secrets with spaces (#13297)
* | 74e1a66 another pass on docs (#13325)
...
|/
* 8cc840f fix(sdk/typescript): resolve referenced values in decorator arguments (#13292)
```

Ran `git merge -s ours 1588421` on 1.0-beta to get this desired git tree:

```
*   ??gitsha?? [1.0-beta] restore merge history with main@15884210ff lost due to squash in fd0021b
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| ...
* | 94ebacb (origin/1.0-beta) update sdk docs, type-system docs, and interfaces (#13338)
* | 64eba3f (tag: v1.0.0-beta.3) [1.0-beta] feat: support synthetic workspaces (#13217)
* | fd0021b Merge main into 1.0-beta (#13327)
* | c6dd435 fix(cli): refine cloud check replay
```
tiborvass added a commit that referenced this pull request Jun 6, 2026
…ash in fd0021b

This merge commit restores the history link between 1.0-beta branch and main.
It was lost with merge commit fd0021b which
squashed the branch e45e7e4

Git tree on #13327 before squash-merging into 1.0-beta:

```
* e45e7e4 Run dagger generate
*   a01677a Merge main into 1.0-beta
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| * 20b2554 Simplify function call return handling (#13319)
| * 316ca15 Fix snapshot owner lease attach/remove race (#13321)
| * 6cfdcb4 fix(layercopy): follow source symlinks when copying directory contents (#13326)
| * 16e85ca Container exists expand option (#13310)
| * 54f9811 chore: post-release during v0.21.4 (#13316)
| * de85595 ci: bump default engine version to v0.21.3 (#13315)
| * 81bb907 chore: prep for v0.21.4 (#13314)
| * 0fd148e Show root usage when dagger has no args
| * 219b696 Volatile vars (#13223)
| * fae340c fix(layercopy): materialize resolved parent dirs when writing through… (#13308)
| * b720144 bump dang (#13306)
| * 41a7910 fix(engine): lease parent layer content for tarball export (#13307)
| * b2d43ba fix(core): attach never-cached module function results (#13298)
| * 6a7b3a7 fix incorrect artifact caching issue when releasing  (#13285)
| * 2452472 fix(core/dotenv): accept `export`-prefixed lines in .env files (#13293)
| * 24b06e7 fix: allow empty setSecret name (#13304)
| * f7ea195 fix: handle 1Password secrets with spaces (#13297)
* | 74e1a66 another pass on docs (#13325)
...
|/
* 8cc840f fix(sdk/typescript): resolve referenced values in decorator arguments (#13292)
```

Ran `git merge -s ours 1588421` on 1.0-beta to get this desired git tree:

```
*   ??gitsha?? [1.0-beta] restore merge history with main@15884210ff lost due to squash in fd0021b
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| ...
* | 94ebacb update sdk docs, type-system docs, and interfaces (#13338)
* | 64eba3f [1.0-beta] feat: support synthetic workspaces (#13217)
* | fd0021b Merge main into 1.0-beta (#13327)
* | c6dd435 fix(cli): refine cloud check replay
* | 74e1a66 another pass on docs (#13325)
```
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.

2 participants