fabric-error-handling
Skill1 starsChanged 56 days agoMITView on GitHub
Use when writing error handling in Fabric notebooks — the Tier 1 (setup, preconditions, hard-fail, raise immediately) vs Tier 2 (bulk operations, soft-fail, track per-item, print summary) convention. Covers the canonical `results = {succeeded, skipped, failed}` shape, the STRICT=False default for scheduled runs, STRICT=True for CI/orchestration, per-item metrics with a parallel per_item list, boundary rules (Tier 1 helpers may be called inside Tier 2 loops; don't wrap Tier 1 in try/except at the notebook level), and anti-patterns to avoid (silent continue, parallel bookkeeping lists).
In this repository62 other files it gives its agents.
- claude/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- author-skillSkill
- drift-auditSkill
- drift-handoffSkill
- drift-updateSkill
- test-skillSkill
- triageSkill
- fabric-activatorSkill
- fabric-ai-functionsSkill
- fabric-authSkill
- fabric-catalog-governanceSkill
- fabric-cicdSkill
- fabric-cliSkill
- fabric-copy-jobSkill
- fabric-data-agentSkill
- fabric-databaseSkill
- fabric-dataflowSkill
- fabric-data-pipelineSkill
- fabric-deployment-pipelinesSkill
- fabric-eventhouseSkill
- fabric-event-schema-setSkill
- fabric-eventstreamSkill
- fabric-gotchasSkill
- fabric-graphSkill
- fabric-mirroringSkill
- fabric-mlvSkill
- fabric-ontologySkill
- fabric-operations-agentSkill
- fabric-realtime-dashboardSkill
- fabric-rest-apiSkill
- fabric-securitySkill
- fabric-semantic-model-ai-instructionsSkill
- fabric-semantic-model-auditSkill
- fabric-spark-monitoringSkill
- fabric-sparkSkill
- fabric-tmdl-apiSkill
- fabric-tmdlSkill
- fabric-variable-librarySkill
- fabric-warehouse-monitoringSkill
- fabric-warehouseSkill
- learnSkill
- pbid-tom-liveSkill
- pbip-project-structureSkill
- pbir-bookmarksSkill
- pbir-cliSkill
- pbir-conditional-formattingSkill
- pbir-filtersSkill
- pbir-pagesSkill
- pbir-report-workflowSkill
- pbir-themesSkill
- pbir-visual-jsonSkill
- powerbi-report-authoringSkill
- powerbi-report-designSkill
- linkedin-highlightsSkill
- msix-packagingSkill
- code-reviewSkill
- commitSkill
- find-sessionSkill
- landSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 55
Every Tier 2 notebook exposes a top-level boolean in its config cell:
- Very specific: line 66
After the summary, if STRICT and results["failed"]: raise RuntimeError(...).
- Distinctive: line 71
Do NOT wrap Tier 1 calls in try/except at the notebook level "just in case".
- Distinctive: line 72
Do NOT convert Tier 1 to print-based warnings for readability.
- Very specific: line 76
Keep a parallel per_table = [] (or per_item = []) list for metrics that don't fit in {"name": str}.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Error handling convention (Fabric notebooks)
Two tiers. Pick the right one per block of code; don't mix them inside a single logical operation.
Tier 1 — Setup / preconditions (hard fail)
Raise immediately. No try/except wrapping, no "best effort" semantics. Applies to:
- Auth: token acquisition, Key Vault secret fetches, connection-string pulls
- Required-config validation: missing required variables, unset placeholders that would produce invalid requests
- Target resolution where the target is a single item: resolve a workspace ID, resolve an item ID, lookup the Variable Library GUID
Tier 1 functions surface the cause in the exception message (HTTP status, what was missing, what was searched). They never swallow errors to keep the notebook running — if a precondition fails, subsequent cells will produce misleading output or worse, silent data corruption.
Tier 2 — Bulk operations (soft fail)
Track per-item results, continue the loop, print a summary at the end. Applies to:
- Per-table maintenance (OPTIMIZE, VACUUM, TBLPROPERTIES alterations)
- Per-item enumeration (list all items, extract GUIDs, update a set of value sets)
- Per-workspace iteration
Canonical result shape — use this exact structure in every Tier 2 notebook:
results = {
"succeeded": [], # list[str] of item names
"skipped": [], # list[dict]: {"name": str, "reason": str}
"failed": [], # list[dict]: {"name": str, "error": str}
}Append into succeeded / skipped / failed inside the loop, never halt the loop on a single failure, then print a summary block at the end:
── Summary ───────────────────────────────────
Succeeded: 47
Skipped: 2
Failed: 1
- `dbo`.`TransactionLine`: snapshot conflict (24556) — retrySTRICT flag
Every Tier 2 notebook exposes a top-level boolean in its config cell:
# False (default) — print the summary and continue even if some items failed.
# Right for scheduled runs: one bad item shouldn't stop the
# rest of the work, and the per-item report is enough signal.
# True — raise RuntimeError after the summary when any item failed. Use from
# CI / orchestration where you want the notebook exit code to reflect state.
STRICT = FalseAfter the summary, if STRICT and results["failed"]: raise RuntimeError(...). The default is False — best-effort with a clear report is what most maintenance runs want.
Boundaries
- A Tier 2 loop's body can call Tier 1 helpers; the try/except inside the loop catches their exceptions and routes them into
failed. - Do NOT wrap Tier 1 calls in try/except at the notebook level "just in case". That masks real problems and produces output that looks like success.
- Do NOT convert Tier 1 to print-based warnings for readability. Raise loudly; the summary shape is only for bulk work.
Per-item metrics (when the canonical shape isn't enough)
Keep a parallel per_table = [] (or per_item = []) list for metrics that don't fit in {"name": str}. Example: OPTIMIZE reports files added/removed per table. Canonical results still drives succeeded/skipped/failed counts; the metrics table is extra detail in the summary.
Anti-patterns to avoid
print("WARNING: ...")with no structured tracking — lost in notebook output, no way to aggregate across a large run.failed_tables = []parallel toresults = []— duplicate bookkeeping, easy to drift out of sync. Use the canonical shape and a single source of truth.try: ...; except Exception as e: print(e); continuewith noresultsentry — the loop keeps going but the failure disappears. Always append toresults["failed"].- Ignoring
STRICTfor "just this one notebook" — the flag should exist everywhere Tier 2 applies, even when it's always left atFalse, because CI callers need a predictable switch.
Reference
- Microsoft Learn: NotebookUtils notebook run and orchestration —
exit(),runMultiple(), the don't-wrap-exit()-in-try/except rule - Microsoft Learn: Errors and Conditional execution (pipeline patterns) — Try-Catch / Do-If-Else / Do-If-Skip-Else
- Microsoft Learn: Fabric notebooks troubleshooting guide
- Comprehensive MS Learn link bundle (notebook exit/runMultiple/DAG / pipeline error paths / Fail activity / Spark exception classes / workspace monitoring): references/REFERENCE.md
See also
- fabric-spark skill — notebook environment the tiers apply to
- fabric-gotchas skill — cross-cutting error causes (snapshot conflict, auth, etc.)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

