<#7351 fix: make copilot task metadata parsing nil...
# flyte-github
a
#7351 fix: make copilot task metadata parsing nil-safe Pull request opened by xjerod Tracking issue N/A Why are the changes needed? Flyte v2 devbox could panic while reconciling a CoPilot-enabled
TaskAction
. The panic was caused by CoPilot logging dereferencing
TaskExecutionIdentifier.TaskId
directly when that field could be nil (
flyteplugins/go/tasks/pluginmachinery/flytek8s/copilot.go:227
). The v2 executor metadata path now derives that task id from the inline task template instead of leaving it absent (
executor/pkg/plugin/task_exec_metadata.go
). What changes were proposed in this pull request? • Populate
TaskExecutionIdentifier.TaskId
from the inline serialized
TaskTemplate.id
. • Make CoPilot task-name logging nil-safe when task metadata is incomplete. • Fix the CoPilot output log argument order. How was this patch tested? Added focused unit coverage for: • Task id propagation from
TaskTemplate.id
into executor metadata. • CoPilot handling when
TaskExecutionIdentifier.TaskId
is nil. Ran: go test ./executor/pkg/plugin ./flyteplugins/go/tasks/pluginmachinery/flytek8s Also built and imported a patched
flyte-binary-v2:sandbox
image into the local devbox containerd for manual validation. Labels fixed Setup process N/A Logs Observed before the fix:
Copy code
{"json":{"src":"copilot.go:176"},"level":"info","msg":"Enabling CoPilot on main container [rtn8lvm8dnm6v6lmwppw-6rhn6rc8kwr6u1xzo28zwh14-0]","ts":"2026-05-07T14:21:06Z"}
{"json":{"src":"copilot.go:217"},"level":"info","msg":"CoPilot Enabled for task []","ts":"2026-05-07T14:21:06Z"}
2026-05-07T14:21:06Z    INFO    Observed a panic in reconciler: runtime error: invalid memory address or nil pointer dereference        {"controller": "taskaction", "controllerGroup": "flyte.org", "controllerKind": "TaskAction", "TaskAction": {"name":"rtn8lvm8dnm6v6lmwppw-6rhn6rc8kwr6u1xzo28zwh14","namespace":"flyte"}, "namespace": "flyte", "name": "rtn8lvm8dnm6v6lmwppw-6rhn6rc8kwr6u1xzo28zwh14", "reconcileID": "72ea04c7-faf8-4fa6-9f55-6f8c8055c873"}
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x23f5150]

goroutine 594 [running]:
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile.func1()
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.3/pkg/internal/controller/controller.go:116 +0x19c
panic({0x2ff96e0?, 0x6570f10?})
        /usr/local/go/src/runtime/panic.go:792 +0x124
github.com/flyteorg/flyte/v2/flyteplugins/go/tasks/pluginmachinery/flytek8s.AddCoPilotToPod({0x3f445a8, 0x400c07bcb0}, {{0x38754fa, 0xe}, {0x4000f32f30, 0x2a}, {0x387f12b, 0x11}, {0x388290d, 0x12}, ...}, ...)
        /flyteorg/build/flyteplugins/go/tasks/pluginmachinery/flytek8s/copilot.go:227 +0x440
github.com/flyteorg/flyte/v2/flyteplugins/go/tasks/pluginmachinery/flytek8s.ApplyFlytePodConfiguration({0x3f445a8, 0x400c07bcb0}, {0x3f6bb40, 0x400b9d15e0}, 0x400b9dcd88, 0x400c0f00f0, {0x400c0bc150, 0x2f})
        /flyteorg/build/flyteplugins/go/tasks/pluginmachinery/flytek8s/pod_helper.go:584 +0x9c0
github.com/flyteorg/flyte/v2/flyteplugins/go/tasks/plugins/k8s/pod.plugin.BuildResource({}, {0x3f445a8, 0x400c07bcb0}, {0x3f6bb40, 0x400b9d15e0})
        /flyteorg/build/flyteplugins/go/tasks/plugins/k8s/pod/plugin.go:121 +0x7dc
github.com/flyteorg/flyte/v2/executor/pkg/plugin/k8s.(*PluginManager).launchResource(0x40000dc3c0, {0x3f445a8, 0x400c07bcb0}, {0x3f6bb40, 0x400b9d15e0})
        /flyteorg/build/executor/pkg/plugin/k8s/plugin_manager.go:100 +0x54
github.com/flyteorg/flyte/v2/executor/pkg/plugin/k8s.(*PluginManager).Handle(0x40000dc3c0, {0x3f445a8, 0x400c07bcb0}, {0x3f6bb40, 0x400b9d15e0})
        /flyteorg/build/executor/pkg/plugin/k8s/plugin_manager.go:222 +0x31c
github.com/flyteorg/flyte/v2/executor/pkg/controller.(*TaskActionReconciler).Reconcile(0x40011114a0, {0x3f445a8, 0x400c07bcb0}, {{{0x400b6f63d6?, 0x5?}, {0x400b6a0150?, 0x400bda1d08?}}})
        /flyteorg/build/executor/pkg/controller/taskaction_controller.go:312 +0x7d8
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0x3f54578?, {0x3f445a8?, 0x400c07bcb0?}, {{{0x400b6f63d6?, 0xb?}, {0x400b6a0150?, 0x0?}}})
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.3/pkg/internal/controller/controller.go:119 +0x80
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0x4001111540, {0x3f445e0, 0x4000989b80}, {0x329b7c0, 0x400117bac0})
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.3/pkg/internal/controller/controller.go:316 +0x2c8
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0x4001111540, {0x3f445e0, 0x4000989b80})
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.3/pkg/internal/controller/controller.go:266 +0x150
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.3/pkg/internal/controller/controller.go:227 +0x70
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2 in goroutine 561
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.16.3/pkg/internal/controller/controller.go:223 +0x3fc
Check all the applicable boxes • I updated the documentation accordingly. • Relevant tests passed. • All commits are signed-off. Related PRs N/A Stack Docs link N/A flyteorg/flyte