Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

fix: align task id generation with spec

wulien23cb9f8d8b1b
diff --git a/internal/pipeline/workdir.go b/internal/pipeline/workdir.go
index 7f808044..deea4179 100644
--- a/internal/pipeline/workdir.go
+++ b/internal/pipeline/workdir.go
@@ -24,11 +24,14 @@ func ResolveWorkdir(input, explicit string) (string, string, error) {
func makeTaskID(input string) string {
trimmed := strings.TrimSpace(input)
last := trimmed
- if parsed, err := url.Parse(trimmed); err == nil && parsed.Path != "" {
- parts := strings.Split(strings.Trim(parsed.Path, "/"), "/")
- last = parts[len(parts)-1]
+ if trimmed == "" {
+ last = "task"
+ } else if parsed, err := url.Parse(trimmed); err == nil {
if v := parsed.Query().Get("v"); v != "" {
last = v
+ } else if parsed.Path != "" {
+ parts := strings.Split(strings.Trim(parsed.Path, "/"), "/")
+ last = parts[len(parts)-1]
}
}
last = strings.ReplaceAll(last, " ", "")
@@ -36,7 +39,11 @@ func makeTaskID(input string) string {
if len(runes) > 16 {
runes = runes[:16]
}
- base := util.SanitizePathName(string(runes))
+ baseInput := string(runes)
+ if strings.TrimSpace(baseInput) == "" {
+ baseInput = "task"
+ }
+ base := util.SanitizePathName(baseInput)
if base == "" {
base = "task"
}
diff --git a/internal/pipeline/workdir_test.go b/internal/pipeline/workdir_test.go
index 7ac3fcb8..3adbadfa 100644
--- a/internal/pipeline/workdir_test.go
+++ b/internal/pipeline/workdir_test.go
@@ -42,3 +42,17 @@ func TestNormalizeLocalInput(t *testing.T) {
t.Fatalf("NormalizeInput(url) = %q", got)
}
}
+
+func TestMakeTaskIDEmptyInputUsesTaskFallback(t *testing.T) {
+ got := makeTaskID("")
+ if !strings.HasPrefix(got, "task_") {
+ t.Fatalf("makeTaskID(empty) = %q, want task_ prefix", got)
+ }
+}
+
+func TestMakeTaskIDUsesQueryVWithoutPath(t *testing.T) {
+ got := makeTaskID("https://example.com?v=abc123")
+ if !strings.HasPrefix(got, "abc123_") {
+ t.Fatalf("makeTaskID(query v) = %q, want abc123_ prefix", got)
+ }
+}