v1.3.53: лintер проверяет entrypoint — файл и функция должны существовать в архиве

Entrypoint формат module.function: лintер ищет module.py в архиве
и проверяет что def function(...) определена внутри.
Если нет — сразу ошибка, не нужно ждать таймаута вызова.
Фронтенд передаёт entrypoint из поля e-entry / ca-entry.
This commit is contained in:
“Naeel”
2026-05-04 09:21:31 +04:00
parent 06389a425d
commit 353cc0f5b1
4 changed files with 65 additions and 3 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ spec:
serviceAccountName: fission-console
containers:
- name: console
image: naeel/fission-console:v1.3.52
image: naeel/fission-console:v1.3.53
imagePullPolicy: Always
ports:
- containerPort: 8090
+57
View File
@@ -58,6 +58,9 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) {
return
}
// Опциональный entrypoint для проверки наличия файла в архиве (формат: "module.function")
entrypoint := strings.TrimSpace(r.FormValue("entrypoint"))
f, _, err := r.FormFile("archive")
if err != nil {
writeJSONError(w, http.StatusBadRequest, "поле 'archive' обязательно")
@@ -196,6 +199,60 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) {
return
}
// Проверяем entrypoint: формат "module.function" → файл "module.py" должен быть в архиве
if entrypoint != "" {
parts := strings.SplitN(entrypoint, ".", 2)
if len(parts) == 2 {
module := parts[0]
funcName := parts[1]
// Ищем файл module.py в архиве (поддерживаем вложенные пути)
foundFile := false
funcDefined := false
for _, zf := range zr.File {
base := strings.TrimSuffix(filepath.Base(zf.Name), ".py")
if base == module && strings.HasSuffix(zf.Name, ".py") {
foundFile = true
// Читаем содержимое и ищем определение функции
rc, openErr := zf.Open()
if openErr == nil {
var content bytes.Buffer
content.ReadFrom(rc) //nolint:errcheck
rc.Close()
for _, line := range strings.Split(content.String(), "\n") {
trimmed := strings.TrimSpace(line)
if strings.HasPrefix(trimmed, "def "+funcName+"(") || trimmed == "def "+funcName+":" {
funcDefined = true
break
}
}
}
break
}
}
if !foundFile {
results = append(results, lintResult{
File: entrypoint,
OK: false,
Output: fmt.Sprintf("файл '%s.py' не найден в архиве — проверьте Entrypoint", module),
})
hasError = true
} else if !funcDefined {
results = append(results, lintResult{
File: entrypoint,
OK: false,
Output: fmt.Sprintf("функция '%s' не найдена в '%s.py' — проверьте Entrypoint", funcName, module),
})
hasError = true
} else {
results = append(results, lintResult{
File: entrypoint,
OK: true,
Output: fmt.Sprintf("entrypoint '%s' найден", entrypoint),
})
}
}
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]any{
"ok": !hasError,
+2 -2
View File
@@ -102,7 +102,7 @@
<div class="nubes">NUBES</div>
<div class="product">FISSION CONSOLE</div>
</div>
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.52</div>
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.53</div>
</div>
<div class="row" style="margin:0;">
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
@@ -462,7 +462,7 @@
</div>
<div class="actions" style="justify-content:space-between; align-items:center;">
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.52</span>
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.53</span>
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
</div>
</div>
+5
View File
@@ -44,6 +44,11 @@ function lintArchiveFile(prefix) {
showRes('Запускаю линтер…', 'var(--bg-alt)', 'var(--fg)');
var fd = new FormData();
fd.append('archive', file);
// Передаём entrypoint для проверки наличия файла и функции в архиве
var entryEl = document.getElementById(prefix + '-entry');
if (entryEl && entryEl.value.trim()) {
fd.append('entrypoint', entryEl.value.trim());
}
fetch(API_BASE + '/ai/lint-archive', {
method: 'POST',
headers: authHeaders(),