Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cue: incorrect cyclic task dependency error #3108

Open
networkhermit opened this issue May 1, 2024 · 1 comment
Open

cmd/cue: incorrect cyclic task dependency error #3108

networkhermit opened this issue May 1, 2024 · 1 comment
Labels
NeedsInvestigation Triage Requires triage/attention

Comments

@networkhermit
Copy link

What version of CUE are you using (cue version)?

$ cue version
cue version 0.8.1

go version go1.22.2
      -buildmode pie
       -compiler gc
       -trimpath true
  DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1

Does this issue reproduce with the latest stable release?

Yes.

What did you do?

  1. copy the following code to test_tool.cue
package main

import (
	"tool/exec"
)

command: test: [string]: [string]: exec.Run

command: test: {
	group1: x={
		let tasks = [
			{cmd: "echo a"},
			{cmd: "echo b"},
			{cmd: "echo c"},
		]
		for i, v in tasks {
			"s\(i+1)": v & {
				if i != 0 {
					$after: x["s\(i)"]
				}
			}
		}
	}
	group2: x={
		let tasks = [
			{cmd: "echo x"},
			{cmd: "echo y"},
			{cmd: "echo z"}, // reduce the list elements to 2, e.g. comment this line, invalidate the cyclic error
		]
		for i, v in tasks {
			"s\(i+1)": v & {
				if i == 0 {
					$after: [for v in group1 {v}]
				}
				if i != 0 {
					$after: x["s\(i)"] // or change this reference to [x["s\(i)"]]
				}
			}
		}
	}
}
  1. run cue cmd test

P.S.

The comments in the above code point two modifications which won't trigger the cyclic error.

What did you expect to see?

a
b
c
x
y
z

What did you see instead?

cyclic task dependency:
        task command.test.group2.s1 refers to
        task command.test.group2.s2 refers to
        task command.test.group2.s1:
    ./test_tool.cue:7:36
@networkhermit networkhermit added NeedsInvestigation Triage Requires triage/attention labels May 1, 2024
@networkhermit
Copy link
Author

Catched another incorrect snippet. Unfortunately this time I'm out of luck.

cue cmd test
cyclic task dependency:
        task command.test.s2 refers to
        task command.test.s3 refers to
        task command.test.s2:
    ./test_tool.cue:7:26
package main

import (
	"tool/exec"
)

command: test: [string]: exec.Run

command: test: X={
	let tasks = [
		{cmd: "echo a"},
		{cmd: "echo 1"},
		{cmd: "echo 2", $dep: [0]},
		{cmd: "echo 3", $dep: [0]},
		{cmd: "echo 4", $dep: [0]},
		{cmd: "echo 5", $dep: [0]},
		{cmd: "echo z", $dep: [1, 2, 3, 4, 5]},
	]
	for i, v in tasks {
		"s\(i+1)": v & {
			if i != 0 {
				let p = (v.$dep & [...int]) != _|_
				if p {
					$after: [for i in v.$dep {X["s\(i+1)"]}]
				}
				if !p {
					$after: [X["s\(i)"]]
				}
			}
		}
	}
}

cue eval output seems ok.

cue eval - < test_tool.cue
command: {
    test: {
        s1: {
            $id: "tool/exec.Run"
            cmd: "echo a"
            env: {} | []
            stdout:      null
            stderr:      null
            stdin:       null
            success:     bool
            mustSucceed: true
        }
        s2: {
            $id: "tool/exec.Run"
            cmd: "echo 1"
            env: {} | []
            stdout:  null
            stderr:  null
            stdin:   null
            success: bool
            $after: [{
                $id: "tool/exec.Run"
                cmd: "echo a"
                env: {} | []
                stdout:      null
                stderr:      null
                stdin:       null
                success:     bool
                mustSucceed: true
            }]
            mustSucceed: true
        }
        s3: {
            $id: "tool/exec.Run"
            cmd: "echo 2"
            env: {} | []
            stdout:  null
            stderr:  null
            stdin:   null
            success: bool
            $after: [{
                $id: "tool/exec.Run"
                cmd: "echo a"
                env: {} | []
                stdout:      null
                stderr:      null
                stdin:       null
                success:     bool
                mustSucceed: true
            }]
            $dep: [0]
            mustSucceed: true
        }
        s4: {
            $id: "tool/exec.Run"
            cmd: "echo 3"
            env: {} | []
            stdout:  null
            stderr:  null
            stdin:   null
            success: bool
            $after: [{
                $id: "tool/exec.Run"
                cmd: "echo a"
                env: {} | []
                stdout:      null
                stderr:      null
                stdin:       null
                success:     bool
                mustSucceed: true
            }]
            $dep: [0]
            mustSucceed: true
        }
        s5: {
            $id: "tool/exec.Run"
            cmd: "echo 4"
            env: {} | []
            stdout:  null
            stderr:  null
            stdin:   null
            success: bool
            $after: [{
                $id: "tool/exec.Run"
                cmd: "echo a"
                env: {} | []
                stdout:      null
                stderr:      null
                stdin:       null
                success:     bool
                mustSucceed: true
            }]
            $dep: [0]
            mustSucceed: true
        }
        s6: {
            $id: "tool/exec.Run"
            cmd: "echo 5"
            env: {} | []
            stdout:  null
            stderr:  null
            stdin:   null
            success: bool
            $after: [{
                $id: "tool/exec.Run"
                cmd: "echo a"
                env: {} | []
                stdout:      null
                stderr:      null
                stdin:       null
                success:     bool
                mustSucceed: true
            }]
            $dep: [0]
            mustSucceed: true
        }
        s7: {
            $id: "tool/exec.Run"
            cmd: "echo z"
            env: {} | []
            stdout:  null
            stderr:  null
            stdin:   null
            success: bool
            $after: [{
                $id: "tool/exec.Run"
                cmd: "echo 1"
                env: {} | []
                stdout:  null
                stderr:  null
                stdin:   null
                success: bool
                $after: [{
                    $id: "tool/exec.Run"
                    cmd: "echo a"
                    env: {} | []
                    stdout:      null
                    stderr:      null
                    stdin:       null
                    success:     bool
                    mustSucceed: true
                }]
                mustSucceed: true
            }, {
                $id: "tool/exec.Run"
                cmd: "echo 2"
                env: {} | []
                stdout:  null
                stderr:  null
                stdin:   null
                success: bool
                $after: [{
                    $id: "tool/exec.Run"
                    cmd: "echo a"
                    env: {} | []
                    stdout:      null
                    stderr:      null
                    stdin:       null
                    success:     bool
                    mustSucceed: true
                }]
                $dep: [0]
                mustSucceed: true
            }, {
                $id: "tool/exec.Run"
                cmd: "echo 3"
                env: {} | []
                stdout:  null
                stderr:  null
                stdin:   null
                success: bool
                $after: [{
                    $id: "tool/exec.Run"
                    cmd: "echo a"
                    env: {} | []
                    stdout:      null
                    stderr:      null
                    stdin:       null
                    success:     bool
                    mustSucceed: true
                }]
                $dep: [0]
                mustSucceed: true
            }, {
                $id: "tool/exec.Run"
                cmd: "echo 4"
                env: {} | []
                stdout:  null
                stderr:  null
                stdin:   null
                success: bool
                $after: [{
                    $id: "tool/exec.Run"
                    cmd: "echo a"
                    env: {} | []
                    stdout:      null
                    stderr:      null
                    stdin:       null
                    success:     bool
                    mustSucceed: true
                }]
                $dep: [0]
                mustSucceed: true
            }, {
                $id: "tool/exec.Run"
                cmd: "echo 5"
                env: {} | []
                stdout:  null
                stderr:  null
                stdin:   null
                success: bool
                $after: [{
                    $id: "tool/exec.Run"
                    cmd: "echo a"
                    env: {} | []
                    stdout:      null
                    stderr:      null
                    stdin:       null
                    success:     bool
                    mustSucceed: true
                }]
                $dep: [0]
                mustSucceed: true
            }]
            $dep: [1, 2, 3, 4, 5]
            mustSucceed: true
        }
    }
}

@networkhermit networkhermit changed the title cmd/cue: wrong cyclic task dependency error cmd/cue: incorrect cyclic task dependency error May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Triage Requires triage/attention
Projects
None yet
Development

No branches or pull requests

1 participant