Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Script Failure

Direct answer

Script Failure isolates interpreter, parsing, control-flow, dependency, command-execution and exit-status failures in a specific script invocation without assuming the last printed error is the root cause.

When to use this

Use it when the symptom is “Script Failure”: work through the layers in order and stop at the first one that fails.

First 30 seconds

1. Script failure: read the error and exit code.

2. Trace execution.

3. Compare environments (interactive vs scheduler).

4. Check inputs.

5. Fix and add test.

Operational verification

script → error → trace → fix

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
automation troubleshooting and failure analysis
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformautomation troubleshooting and failure analysis · Script Failure owns generic script-runtime isolation. PowerShell-, Python- and Bash-specific language semantics belong in their scripting/platform branches. · Python
Key commandpython -c "import ast,pathlib; ast.parse(pathlib.Path('<script.py>').read_text())"
Scope / prerequisiteUse it when the symptom is “Script Failure”: work through the layers in order and stop at the first one that fails.
Reference · 1
What next?3 suggested next steps
Catalog command links1
Evidence1
On this pageJump to a specific section
Automation command reference

Primary Commands

Configuration and operational commands for this Topic.

Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

7 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

invocation → script revision → interpreter/environment → input validation → parse/control flow → function/module → child command/API → exit/exception → partial target state → acceptance test

Healthy evidence: script revision and runtime context are pinned, the first exception/exit boundary is reproducible, partial effects are known, and the corrected invocation passes target read-back and acceptance.

Step 2 Telling causes apart Verify boundary

Known-good begins with the AST parse completing successfully (process exit code 0) for the intended source revision, then the original script invocation completing with the expected exit code/output and target state. Broken state is a deterministic SyntaxError/parse failure or a clean parse followed by a repeatable runtime boundary failure. AST success shows Python syntax only, but it does not show imports, runtime logic, credentials or downstream operations.

Step 3 Common mistakes Verify boundary
  • Reading only the last log line.
  • Re-running without understanding what already changed.
Step 4 Verification path Verify boundary

To verify Script Failure, first record run/request/job ID, definition revision, target identity, attempt number, timestamp and correlation/error identifier. Then check the result reported by the tool, and finally read the concrete target state and the earliest subsystem that can show or disprove the failure hypothesis directly and compare it with what you intended.

Also test the cases that usually go wrong: blind retry loops, overwriting the first error, widening privileges, conflating timeout with non-execution, hiding partial success and treating a controller status as target-evidence of the actual state.

Step 5 Failure modes and next checks Narrow the fault

Suspicious evidence: only a generic job error is available, the script changed between attempts, environment differences are ignored, or partial side effects are never inspected.

Step 6 Observation-driven branch and next-check logic Narrow the fault

First preserve the exact invocation, input and error/exit code. Run python -c "import ast,pathlib; ast.parse(pathlib.Path('<script.py>').read_text())" against the same source revision. If parsing fails, correct the reported syntax location before investigating runtime; if parsing succeeds, reproduce with the same interpreter/environment and inspect imports, input validation and the first failing external boundary. If an external command fails, record its exit code/stdout/stderr rather than masking it with generic exception handling.

Step 7 Where it fails Narrow the fault

Typical problems with Script Failure: blind retry loops, overwriting the first error, widening privileges, conflating timeout with non-execution, hiding partial success and treating a controller status as target-evidence of the actual state.

Before you retry a change, read the target's current state first, using run/request/job ID, definition revision, target identity, attempt number, timestamp and correlation/error identifier.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Non-zero exit ≠ no target-side changes occurred.
  • Last stack-frame message ≠ earliest causal failure.
  • Script runs interactively ≠ automation invocation has identical environment.
  • Exit code 0 ≠ desired state verified.
Key checks
  • bash -x script.sh / Set-PSDebug -Trace 1 / python3 -m pdb — trace
  • Exit code and stderr — error
  • Environment differences (PATH, user, cwd) — context
ReferenceWhat it is1 section · depth on demand

Core model

Pin script content/hash, interpreter/version, invocation, parameters, environment and working directory; reproduce with the same inputs; identify parse/runtime/function/module/child-process boundary; capture stderr, exception stack and exit code; inspect any partial side effects; fix the earliest defect; rerun with original inputs and verify target state.

ReferenceHow it works2 sections · depth on demand

How it works and how it fails

Script Failure can originate before execution (parse/load), during dependency/import resolution, inside business logic, or from an external command/API invoked by the script. Python's AST parser owns only syntax validity for a selected source file; runtime environment, inputs and side effects are separate stages. A script that parses cleanly can still fail on imports, permissions, data shape or downstream service state.

In depth

A script failure is a non-zero exit, an unhandled exception or wrong output from a script. The cause is usually in the input, the environment the script ran in, or an external dependency.

CheckCommand
Exit codeecho $?, $LASTEXITCODE
Full errorLast 50 lines of the log, stack trace
EnvironmentInterpreter version, PATH, user
Tracebash -x, Set-PSDebug -Trace 1, python -m pdb

Reproduce with the exact same inputs and user; most "works for me" cases are environment differences.

ReferenceImportant terms & boundaries2 sections · depth on demand

What this shows and what it does not

A script error shows only the observed invocation failed at or after a recorded boundary, but it does not show earlier operations were rolled back or that later targets were untouched.

Mechanics

Durable intent is a bounded diagnostic hypothesis tied to stable run/request/target identity and the earliest observable failing layer; stable identity is run/request/job ID, definition revision, target identity, attempt number, timestamp and correlation/error identifier. The consumer-visible target is the concrete target state and the earliest subsystem that can show or disprove the failure hypothesis. The operating invariants are that the first concrete error is preserved, retries are safe and bounded, unknown completion is distinguished from failure, and final state is re-read independently. Follow the chain of components input/selection → controller/scheduler → worker/executor → transport/provider → target subsystem → consumer-visible state → independent read-back and record which layer currently owns truth.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Lifecycle

A fresh noninteractive execution should be reproducible from source-controlled intent plus documented prerequisites, and the release must retain enough identity to tie every result back to run/request/job ID, definition revision, target identity, attempt number, timestamp and correlation/error identifier.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docautomation troubleshooting and failure analysis current

Authoritative/upstream documentation reviewed for bounded claims in Automation Troubleshooting > Script Failure. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/azure/architecture/patterns/retry · confidence 94%
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
script failureautomation script errorscript runtime failure
Embedded reference data

Quick lookup tables

Script Failure troubleshooting proof-boundary map

Fast symptom/scope, first-failed-boundary, effective-outcome and recovery/closure map for Script Failure.

BoundaryHealthy evidenceSuspicious evidence
Symptom / scopeTime window, immutable source/run identity, effective inputs and exact targets are explicitFloating source, changed inputs or ambiguous targets destroy reproducibility
First failed boundaryTransport/auth/dependency/render/operation evidence identifies the earliest divergenceInvestigation starts at the final error and skips earlier unproven boundaries
Effective outcomeController result is paired with target read-back and workload/service acceptanceGreen execution state or changed symptom substitutes for effective-state verification
Recovery / closureMinimal change restores the original test and regression/partial-state checks are cleanBroad retry or unrelated edits make the incident non-reproducible and hide residual state
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

Capture at minimum run/request ID, target ID, attempt, stage/boundary, status, error class/code/message, timestamps, partial-success set and independent final-state observation.

Confirmation

Confirm action

Continue?