fix: ignore comments and continuations in python lockfiles (#11035)

* fix: ignore comments and continuations in python lockfiles

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVNKkWNGPuggLucMzFeoa1

* fix: warn when a lockfile's hash pins are not enforced

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVNKkWNGPuggLucMzFeoa1

* fix: state only what the continuation warning can know

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVNKkWNGPuggLucMzFeoa1

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-09-08 23:50:50 +02:00
committed by GitHub
co-authored by Claude Opus 5
parent 88c3ebdfc1
commit 90c4e1020a
2 changed files with 103 additions and 8 deletions
+21 -8
View File
@@ -37,8 +37,9 @@ use windmill_common::{
scripts::ScriptLang,
utils::calculate_hash,
worker::{
copy_dir_recursively, is_allowed_file_location, pad_string, split_python_requirements,
write_file, Connection, PyVAlias, PythonAnnotations, WORKER_CONFIG,
copy_dir_recursively, is_allowed_file_location, lockfile_line_has_continuation, pad_string,
requirement_from_lockfile_line, split_python_requirements, write_file, Connection,
PyVAlias, PythonAnnotations, WORKER_CONFIG,
},
};
@@ -227,9 +228,9 @@ fn filter_pip_local_dependencies(lines: Vec<String>) -> (Vec<String>, Vec<String
/// `(kept, ignored)`. A line is ignored when it is not a `#` comment and matches any of
/// `compiled_deps`. Kept separate from config/regex loading so it can be unit-tested.
fn filter_lines_by_deps(lines: Vec<String>, compiled_deps: &[Regex]) -> (Vec<String>, Vec<String>) {
let (ignored, kept): (Vec<String>, Vec<String>) = lines
.into_iter()
.partition(|s| !s.starts_with('#') && compiled_deps.iter().any(|dep| dep.is_match(s)));
let (ignored, kept): (Vec<String>, Vec<String>) = lines.into_iter().partition(|s| {
!s.trim_start().starts_with('#') && compiled_deps.iter().any(|dep| dep.is_match(s))
});
(kept, ignored)
}
@@ -2520,11 +2521,23 @@ pub async fn handle_python_reqs(
// Find out if there is already cached dependencies
// If so, skip them
let mut in_cache = vec![];
if requirements
.iter()
.any(|r| lockfile_line_has_continuation(r))
{
tracing::warn!(workspace_id = %w_id, job_id = %job_id, "lockfile continues entries across lines; the continued lines are dropped");
append_logs(
job_id,
w_id,
"\n[!] lockfile continues entries across lines and the continued lines are dropped: `--hash=` pins, extras and markers written that way do not apply\n".to_string(),
conn,
)
.await;
}
for req in &requirements {
// Ignore python version annotation backed into lockfile
if req.starts_with('#') || req.starts_with('-') || req.trim().is_empty() {
let Some(req) = requirement_from_lockfile_line(req) else {
continue;
}
};
let py_prefix = &py_version.to_cache_dir(false);
let venv_p = format!(