fix(jobs): resolver ops_db_path absoluto y normalizar backslashes

build_stdin_json enviaba ops_db_path tal cual al subprocess Python
(tipicamente "projects/<slug>/operations.db", relativo). Si el cwd
del proceso padre no era el dir del proyecto, sqlite3.connect
creaba un fichero vacio en otra ruta y el primer SELECT fallaba con
"no such table: entities".

Anade lambda absify que normaliza separadores (\\ -> /) antes de
std::filesystem::absolute (en Linux \\ es char literal del nombre,
no separador) y absolutiza ops_db, app_dir y registry_root antes
del to_wsl_path. Cubre los 5 enrichers de una sola vez.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-02 16:10:21 +02:00
parent 6919ebfe9c
commit 5fe856b30e
+28 -3
View File
@@ -12,6 +12,7 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <filesystem>
#include <memory>
#include <mutex>
#include <queue>
@@ -276,9 +277,33 @@ std::string build_stdin_json(const std::string& job_id,
if (!m.empty()) node_metadata = m;
}
std::string ops_db_wsl = to_wsl_path(ops_db);
std::string app_dir_wsl = to_wsl_path(app_dir);
std::string root_wsl = to_wsl_path(registry_root);
// Resolver paths a absoluto antes del to_wsl_path. Si el ops_db
// viene relativo (caso tipico: "projects/<slug>/operations.db"),
// el subprocess Python lo abriria contra su propio cwd y crearia
// un fichero vacio si no coincide. Forzar absoluto evita ese bug.
auto absify = [](const std::string& p) -> std::string {
if (p.empty()) return p;
// Normalizar backslashes a forward slashes ANTES de absolute().
// El path puede venir mezclado (Windows fs::path::string() en
// build cross, copia desde Windows...). Sin esto, std::filesystem
// en Linux trata `\` como caracter literal del nombre.
std::string norm = p;
for (char& c : norm) if (c == '\\') c = '/';
std::error_code ec;
std::filesystem::path fp(norm);
if (fp.is_absolute()) return norm;
auto abs = std::filesystem::absolute(fp, ec);
std::string out = ec ? norm : abs.lexically_normal().string();
for (char& c : out) if (c == '\\') c = '/';
return out;
};
std::string ops_db_abs = absify(ops_db);
std::string app_dir_abs = absify(app_dir);
std::string root_abs = absify(registry_root);
std::string ops_db_wsl = to_wsl_path(ops_db_abs);
std::string app_dir_wsl = to_wsl_path(app_dir_abs);
std::string root_wsl = to_wsl_path(root_abs);
std::string cache_dir = app_dir_wsl + "/cache";
std::ostringstream o;