Skip to content

CLI: don't show stderr twice on error #7007

Closed

Description

@shykes

Problem

When dagger call returns an error, the contents of the error is printed twice to the screen:

  • A first time within the call trace
  • A second time at the end of the output

When the call trace is large, or the error message is long, or both, this makes the output very hard to read. The user will often get lost trying to isolate a useful snippet of text to read.

Solution

Only print the error message once, outside the call trace.

Before After
Show error message within call trace? Yes No
Show error message after call trace? Yes Yes

Here's an example before the change:

$ dagger call -m github.com/dagger/dagger/sdk/python/runtime base-image
✔ initialize 6.1s
  ✔ ModuleSource.asModule: Module! 0.6s
  ✔ Module.initialize: Module! 0.4s
    ✔ exec go build -o /runtime . 0.3s
    ✔ exec /runtime 0.1s
✘ pythonSdk: PythonSdk! 0.1s
  ✘ exec /runtime 0.1s
  ┃ /src/sdk/python/runtime/internal/dagger/dagger.gen.go:2235
  ┃ main.New(0x0)
  ┃ /src/sdk/python/runtime/main.go:63 +0x10c
  ┃ main.invoke({0x3fe3d0, 0x638e00}, {0x40001824b8, 0x4, 0x8}, {0x40001823f0?, 0x4000104c68?}, {0x0?, 0x40000100e0?}, 0x10?)
  ┃ /src/sdk/python/runtime/dagger.gen.go:800 +0x174
  ┃ main.main()
  ┃ /src/sdk/python/runtime/dagger.gen.go:591 +0x4b0
 
Error: response from query: input: pythonSdk resolve: call constructor: process "/runtime" did not complete successfully: exit code: 2
 
Stderr:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2c023c]
 
goroutine 1 [running]:
python-sdk/internal/dagger.(*Directory).WithoutDirectory(...)
 /src/sdk/python/runtime/internal/dagger/dagger.gen.go:2235
main.New(0x0)
 /src/sdk/python/runtime/main.go:63 +0x10c
main.invoke({0x3fe3d0, 0x638e00}, {0x40001824b8, 0x4, 0x8}, {0x40001823f0?, 0x4000104c68?}, {0x0?, 0x40000100e0?}, 0x10?)
 /src/sdk/python/runtime/dagger.gen.go:800 +0x174
main.main()
 /src/sdk/python/runtime/dagger.gen.go:591 +0x4b0

The same output after the proposed change:

$ dagger call -m github.com/dagger/dagger/sdk/python/runtime base-image
✔ initialize 6.1s
  ✔ ModuleSource.asModule: Module! 0.6s
  ✔ Module.initialize: Module! 0.4s
    ✔ exec go build -o /runtime . 0.3s
    ✔ exec /runtime 0.1s
✘ pythonSdk: PythonSdk! 0.1s
  ✘ exec /runtime 0.1s

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2c023c]

goroutine 1 [running]:
python-sdk/internal/dagger.(*Directory).WithoutDirectory(...)
	/src/sdk/python/runtime/internal/dagger/dagger.gen.go:2235
main.New(0x0)
	/src/sdk/python/runtime/main.go:63 +0x10c
main.invoke({0x3fe3d0, 0x638e00}, {0x40001824b8, 0x4, 0x8}, {0x40001823f0?, 0x4000104c68?}, {0x0?, 0x40000100e0?}, 0x10?)
	/src/sdk/python/runtime/dagger.gen.go:800 +0x174
main.main()
	/src/sdk/python/runtime/dagger.gen.go:591 +0x4b0

OSS-242

Activity

  1. added this to the next milestone on Apr 3, 2024
  2. added
    area/cli
    on Apr 3, 2024
  3. assigned and unassigned on May 15, 2024
  4. removed
    area/cli
    on May 31, 2024
  5. added 3 commits that reference this issue on Aug 10, 2024
    aa2cf46
    77c7582
    2dbcf85
  6. added 6 commits that reference this issue on Sep 10, 2024
    9a74a08
    8a1a7e9
    19f0fcc
    3031fb8
    7c093a4
    5526067
  7. added 3 commits that reference this issue on Oct 7, 2024
    f2f0f4d
    4c51da4
    094f9c9
  8. added a commit that references this issue on Nov 13, 2024
    6fdf164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions