{"record":{"id":"a55c8c2d53dda9d5","repo":"windmill-labs/windmill","slug":"internal-error-cannot-resolve-requirement-pins","errorCode":null,"errorMessage":"Internal error: cannot resolve requirement pins","messagePattern":"Internal error: cannot resolve requirement pins","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-py-imports/src/lib.rs","lineNumber":645,"sourceCode":"            //  └── repin:1\n            //\n            match imp.clone() {\n                NImportResolved::Repin { .. } => {\n                    if let Some(existing_import) = final_imports.get(&key) {\n                        match existing_import {\n                            // replace\n                            p if matches!(\n                                p,\n                                NImportResolved::Pin { .. } | NImportResolved::Auto { .. }\n                            ) =>\n                            {\n                                final_imports.insert(key, imp);\n                            }\n                            // do nothing (older repins have greater precedence)\n                            NImportResolved::Repin { .. } => {}\n                            // Should not be possible\n                            _ => {\n                                return Err(anyhow::anyhow!(\n                                    \"Internal error: cannot resolve requirement pins\",\n                                )\n                                .into());\n                            }\n                        }\n                    } else {\n                        final_imports.insert(key, imp.clone());\n                    }\n                }\n                NImportResolved::Pin { pins: new_pins, .. } => {\n                    if let Some(existing_import) = final_imports.get_mut(&key) {\n                        match existing_import {\n                            // Check if pin is the same version, if same, do nothing, if not error\n                            NImportResolved::Pin { pins: existing_pins, .. } => {\n                                existing_pins.extend(new_pins)\n                            }\n                            // do nothing\n                            NImportResolved::Repin { .. } => {}","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-py-imports/src/lib.rs#L627-L663","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Treat it as a bug: capture the script's stored imports/pin state and file an issue on windmill-backend with the script content.","Redeploy or re-save the script so its import/pin metadata is regenerated from scratch.","Check windmill version skew — if a backend was upgraded mid-flight, re-run the operation on a single consistent version.","As a workaround, clear the requirements/pins for the affected script (empty its imports metadata) and re-parse."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# No caller-side validation applies: this is an internal invariant on stored pin state.\n# Guard by clearing stale import-pin metadata before re-parsing:\n# e.g. reset the script's imports/requirements metadata so pins are regenerated\ncode_is_fresh = script_was_redeployed_after_backend_upgrade  # verify freshness","typeGuard":null,"tryCatchPattern":"try:\n    imports = parse_python_imports(code)\nexcept Exception as e:\n    if 'cannot resolve requirement pins' in str(e):\n        log.error('internal pin-state invariant violated; report bug and redeploy script')\n        raise\n    raise","preventionTips":["Redeploy scripts after backend upgrades so pin metadata is regenerated by the same version","Avoid concurrent edits/deploys of the same script while imports are being resolved","Treat occurrences as parser bugs: capture state and file an issue","Keep windmill backend and workers on the same version"],"tags":["python","imports","internal-error","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}