Repository navigation
Closed
Labels
kind/bugSomething isn't working
Description
What is the issue?
I'm trying to write a new file with the following script:
KO
import Client, { connect } from "@dagger.io/dagger"
connect(async (client: Client) => {
const newFile = await client
.container()
.directory("/").entries()
})OK
import Client, { connect } from "@dagger.io/dagger"
connect(async (client: Client) => {
const newFile = await client
.container()
.from("alpine")
.directory("/").entries()
})Log output
(node:41070) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
file:///private/tmp/my-app/node_modules/@dagger.io/dagger/dist/api/utils.js:5
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
^
GraphQLRequestError: Error message
at file:///private/tmp/my-app/node_modules/@dagger.io/dagger/dist/api/utils.js:119:23
at Generator.throw (<anonymous>)
at rejected (file:///private/tmp/my-app/node_modules/@dagger.io/dagger/dist/api/utils.js:5:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
cause: ClientError: runtime error: invalid memory address or nil pointer dereference: {"response":{"data":null,"errors":[{"message":"r
untime error: invalid memory address or nil pointer dereference","locations":[{"line":5,"column":9}],"path":["container","directory"]}],"status":200,"headers":{}},"request":{"query":"\n {\n container {\n \n directory (path: \"/\") {\n \n withNewFile (path: \"myfile\",contents: \"This string has quotes \\\"\") {\n \n file (path: \"myfile\") {\n \n id }}}}\n }\n "}} at /private/tmp/my-app/node_modules/graphql-request/src/index.ts:497:11
at step (/private/tmp/my-app/node_modules/graphql-request/dist/index.js:63:23)
at Object.next (/private/tmp/my-app/node_modules/graphql-request/dist/index.js:44:53)
at fulfilled (/private/tmp/my-app/node_modules/graphql-request/dist/index.js:35:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
response: { data: null, errors: [Array], status: 200, headers: [Headers] },
request: {
query: '\n' +
' {\n' +
' container {\n' +
' \n' +
' directory (path: "/") {\n' +
' \n' +
' withNewFile (path: "myfile",contents: "This string has quotes \\"") {\n' +
' \n' +
' file (path: "myfile") {\n' +
' \n' +
' id }}}}\n' +
' }\n' +
' ',
variables: undefined
}
},
code: 'D100',
requestContext: {
query: '\n' +
' {\n' +
' container {\n' +
' \n' +
' directory (path: "/") {\n' +
' \n' +
' withNewFile (path: "myfile",contents: "This string has quotes \\"") {\n' +
' \n' +
' file (path: "myfile") {\n' +
' \n' +
' id }}}}\n' +
' }\n' +
' ',
variables: undefined
},
response: {
data: null,
errors: [ [Object] ],
status: 200,
headers: Headers { [Symbol(map)]: [Object: null prototype] }
}
}Steps to reproduce
1 - Follow the getting started steps 1 and 2 to install Dagger SDK:
- https://docs.dagger.io/sdk/nodejs/783645/get-started#step-1-create-a-react-application
- https://docs.dagger.io/sdk/nodejs/783645/get-started#step-2-install-the-dagger-nodejs-sdk
2 - Create a new file .ts (eg: build.ts) in your root dir
3 - Copy paste the following script:
import Client, { connect } from "@dagger.io/dagger"
connect(async (client: Client) => {
const stringWithQuotes = "This string has quotes \""
const newFile = await client
.container()
.directory("/")
.withNewFile("myfile", stringWithQuotes)
.file("myfile").id()
})4 - Run this command (if necessary change build.ts with your script name):
node --loader ts-node/esm ./build.tsDagger version
dagger devel (c3124a9) darwin/arm64
OS version
macOs 13.0.1 (22A400)
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working
Activity
slumbering commentedon Dec 8, 2022
cc @aluzzardi @sipsma
slumbering commentedon Dec 22, 2022
Did you get the chance to tackle this issue @sipsma @aluzzardi ? Or maybe I'm doing something wrong in the example above ? Thanks
slumbering commentedon Jan 10, 2023
👋 @sipsma @aluzzardi . Adding
.from('alpine')removes the error.slumbering commentedon Jan 10, 2023
Same error with go:
Building with Dagger [] input:1: container.directory runtime error: invalid memory address or nil pointer dereference Please visit https://dagger.io/help#go for troubleshooting guidance.aluzzardi commentedon Jan 10, 2023
Looks like a bug deep down, not converting a nil pointer into an llb.Scratch
@vito Would you know if there's one magic spot where we could handle that?
vito commentedon Jan 10, 2023
@aluzzardi This error has bubbled up from Buildkit even when dealing with llb.Scratch in various places. I know @sipsma tracked down at least one of them. I haven't found a silver bullet, it feels like playing wack-a-mole. 😕
I tracked this one down to here:
dagger/core/directory.go
Lines 129 to 134 in e88a409
Above it, we already try to handle scratch by special-casing it and setting
payload.LLBtoniland checking for it, but it ended up being set to a marshalledllb.Scratch()instead which is what causes panics.dagger/core/directory.go
Lines 107 to 115 in e88a409
We ended up with a marshaled
llb.Scratch()instead ofnilbecauselocatePathcalledNewDirectory(initbelow) withllb.Scratch()(returned byFSState):dagger/core/container.go
Lines 681 to 690 in e88a409
One way to handle this could be to change
NewDirectoryto take a*llb.Stateto support creating a directory withLLB: nil, but that'll make calls likeNewDirectory(ctx, llb.Image(...), ...)pretty ugly.We can also change
NewDirectoryto check forllb.Scratch()withst.Output() != nilbut I remember there being some situation where that didn't work. 😮💨Long story short this is probably best fixed in upstream Buildkit. It's weird that
llb.Scratch(), a supported API, leads to nil panics in any situation.vito commentedon Feb 13, 2023
Closing optimistically as #4248 (comment) included a fix for this