{"record":{"id":"e15824cd2554c3cc","repo":"flipped-aurora/gin-vue-admin","slug":"error-e15824","errorCode":null,"errorMessage":"脚本类型不支持","messagePattern":"脚本类型不支持","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/sys_skills.go","lineNumber":276,"sourceCode":"\t}\n\n\tif err = zw.Close(); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\treturn req.Skill + \".zip\", buf.Bytes(), nil\n}\n\nfunc (s *SkillsService) CreateScript(_ context.Context, req request.SkillScriptCreateRequest) (string, string, error) {\n\tif !isSafeName(req.Skill) {\n\t\treturn \"\", \"\", errors.New(\"技能名称不合法\")\n\t}\n\tfileName, lang, err := buildScriptFileName(req.FileName, req.ScriptType)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tif lang == \"\" {\n\t\treturn \"\", \"\", errors.New(\"脚本类型不支持\")\n\t}\n\tskillDir, err := s.ensureSkillDir(req.Tool, req.Skill)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tfilePath := filepath.Join(skillDir, \"scripts\", fileName)\n\tif _, err := os.Stat(filePath); err == nil {\n\t\treturn \"\", \"\", errors.New(\"脚本已存在\")\n\t}\n\tif err := os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tcontent := scriptTemplate(lang)\n\tif err := os.WriteFile(filePath, []byte(content), 0644); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\treturn fileName, content, nil\n}","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/sys_skills.go#L258-L294","documentation":"After buildScriptFileName normalizes the requested script type, an unknown type leaves lang empty and CreateScript returns \"脚本类型不支持\". Only \"py/python\", \"js/javascript/script\", and \"sh/shell/bash\" are accepted (case-insensitive).","triggerScenarios":"Calling CreateScript with ScriptType values like \"ts\", \"typescript\", \"rb\", \"go\", \"powershell\", or an empty string.","commonSituations":"Frontend dropdown out of sync with backend enum; user assuming TypeScript is supported; API consumers guessing the type string instead of using the allowed set.","solutions":["Use one of: py/python, js/javascript/script, sh/shell/bash (case-insensitive)","For TypeScript or other languages, create the file manually via SaveScript or add a case to buildScriptFileName","Fix the frontend select options to match the backend's accepted values"],"exampleFix":"// before\n{ \"fileName\": \"build.ts\", \"scriptType\": \"typescript\" }\n// after\n{ \"fileName\": \"build\", \"scriptType\": \"js\" }  // or use SaveScript to write a .ts file manually","handlingStrategy":"validation","validationCode":"var allowed = map[string]bool{\"py\": true, \"python\": true, \"js\": true, \"javascript\": true, \"script\": true, \"sh\": true, \"shell\": true, \"bash\": true}\nif !allowed[strings.ToLower(req.ScriptType)] { /* reject or map before calling */ }","typeGuard":null,"tryCatchPattern":"if err := svc.CreateScript(ctx, req); err != nil {\n    if err.Error() == \"脚本类型不支持\" {\n        return fmt.Errorf(\"脚本类型仅支持 py/js/sh: %w\", err)\n    }\n    return err\n}","preventionTips":["Use a fixed dropdown of py/js/sh values in the UI","Keep frontend options in sync with buildScriptFileName's switch","Normalize case (ToLower) before sending"],"tags":["validation","enum","go"],"backgroundTag":"unsupported-enum-value","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}