windmill-labs/windmill · error

Internal error: cannot resolve requirement pins

Error message

Internal error: cannot resolve requirement pins

What it means

parse_python_imports_inner merges previously stored requirement pins with newly parsed imports via an NImportResolved enum. The match only handles the expected variants (insert new imports, ignore older repins); anything else falls into the catch-all arm, which throws this internal-invariant error — it signals corrupted or unexpected pin state, not user error.

Source

Thrown at backend/parsers/windmill-parser-py-imports/src/lib.rs:645

            //  └── repin:1
            //
            match imp.clone() {
                NImportResolved::Repin { .. } => {
                    if let Some(existing_import) = final_imports.get(&key) {
                        match existing_import {
                            // replace
                            p if matches!(
                                p,
                                NImportResolved::Pin { .. } | NImportResolved::Auto { .. }
                            ) =>
                            {
                                final_imports.insert(key, imp);
                            }
                            // do nothing (older repins have greater precedence)
                            NImportResolved::Repin { .. } => {}
                            // Should not be possible
                            _ => {
                                return Err(anyhow::anyhow!(
                                    "Internal error: cannot resolve requirement pins",
                                )
                                .into());
                            }
                        }
                    } else {
                        final_imports.insert(key, imp.clone());
                    }
                }
                NImportResolved::Pin { pins: new_pins, .. } => {
                    if let Some(existing_import) = final_imports.get_mut(&key) {
                        match existing_import {
                            // Check if pin is the same version, if same, do nothing, if not error
                            NImportResolved::Pin { pins: existing_pins, .. } => {
                                existing_pins.extend(new_pins)
                            }
                            // do nothing
                            NImportResolved::Repin { .. } => {}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Treat it as a bug: capture the script's stored imports/pin state and file an issue on windmill-backend with the script content.
  2. Redeploy or re-save the script so its import/pin metadata is regenerated from scratch.
  3. Check windmill version skew — if a backend was upgraded mid-flight, re-run the operation on a single consistent version.
  4. As a workaround, clear the requirements/pins for the affected script (empty its imports metadata) and re-parse.
Defensive patterns

Strategy: try-catch

Validate before calling

# No caller-side validation applies: this is an internal invariant on stored pin state.
# Guard by clearing stale import-pin metadata before re-parsing:
# e.g. reset the script's imports/requirements metadata so pins are regenerated
code_is_fresh = script_was_redeployed_after_backend_upgrade  # verify freshness

Try / catch

try:
    imports = parse_python_imports(code)
except Exception as e:
    if 'cannot resolve requirement pins' in str(e):
        log.error('internal pin-state invariant violated; report bug and redeploy script')
        raise
    raise

Prevention

When it happens

Trigger: Calling parse_python_imports / parse_python_imports_inner when the stored import-pin state contains an NImportResolved variant the merge logic never anticipates (the code comments this case as 'Should not be possible') — e.g. an inconsistent result from the earlier parse pass or a stale/unknown pin record shape.

Common situations: Rare: partially written or legacy pin metadata in the script's stored imports, a version skew between the code that produced the pin state and the code that consumes it, or an actual bug in the parser's variant construction.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/a55c8c2d53dda9d5. Report an issue: GitHub.