Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion controller/task_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ func updateVideoSingleTask(ctx context.Context, adaptor channel.TaskAdaptor, cha
logger.LogError(ctx, fmt.Sprintf("Task %s not found in taskM", taskId))
return fmt.Errorf("task %s not found", taskId)
}
resp, err := adaptor.FetchTask(baseURL, channel.Key, map[string]any{
key := channel.Key

privateData := task.PrivateData
if privateData.Key != "" {
key = privateData.Key
}
Comment on lines +77 to +82

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Add nil check for task.PrivateData to prevent potential panic.

If task.PrivateData is nil, accessing privateData.Key on line 80 will cause a nil pointer dereference panic. Add a nil check before accessing the struct field.

Apply this diff to add a nil check:

 	key := channel.Key
 
 	privateData := task.PrivateData
-	if privateData.Key != "" {
+	if privateData != nil && privateData.Key != "" {
 		key = privateData.Key
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
key := channel.Key
privateData := task.PrivateData
if privateData.Key != "" {
key = privateData.Key
}
key := channel.Key
privateData := task.PrivateData
if privateData != nil && privateData.Key != "" {
key = privateData.Key
}
🤖 Prompt for AI Agents
In controller/task_video.go around lines 77 to 82, the code reads
task.PrivateData without checking for nil which can cause a nil pointer
dereference; update the logic to first test if task.PrivateData != nil and only
then read privateData.Key, e.g. retrieve privateData into a local var after the
nil check (or check task.PrivateData.Key only when task.PrivateData != nil) and
set key to privateData.Key if present otherwise fall back to channel.Key.

resp, err := adaptor.FetchTask(baseURL, key, map[string]any{
"task_id": taskId,
"action": task.Action,
}, proxy)
Expand Down