# Diagnostics reference

Start with the first error in the file. The highlighted text shows where to look, and the message usually tells you what to change. In Studio, select a code like `SS1101` to look it up here. After editing, check the whole project again.

Errors block the build. Warnings show connections worth reviewing; they do not mean the shortcut ran successfully on a device.

## SS0001

Studio could not read the file or argument.
Fix: check the file path and try again.

## SS0002

Studio could not display the build check result.
Fix: retry Check; if it persists, the message names the underlying problem.

## SS1000

A general source, import, or call error. The message may identify a missing shortcut header, unknown call, invalid argument, or missing module.
Fix: follow the specific message. Entry files need `shortcut:` with indented statements; top-level imports and helper declarations may precede it. Helper-only imported files do not need a shortcut body. Verify exact action names and arguments in the installed catalog.

```shortcuty
shortcut:
  text("hello")
```

## SS1101

Source was found outside the shortcut body.
Fix: indent executable actions inside the `shortcut:` block. Imports, helper declarations, and valid top-level `shared`/`const` declarations stay outside it. `shared` is entry-file-only; helper-local configuration uses `const`.

## SS1102

Tabs were used for indentation.
Fix: use consistent spaces, not tabs. Two spaces per level is recommended. Align sibling statements and dedent to an earlier level. Most editors can convert tabs to spaces.

## SS1103

A closing delimiter (`)`, `]`, or `}`) appeared where none was open.
Fix: remove it, or open the matching `(`, `[`, `{` earlier.

## SS1104

A line is indented but the line above it can't start a block.
Fix: only block headers (`if …:`, `for …:`, `def …:`, `menu …:`, etc.) open
nested blocks — dedent the line or fix the header above it.

## SS1201

An expression couldn't be parsed. The message quotes the offending part.
Fix: check operators, parentheses, and string quotes in that expression. Numeric literals must be finite; use a smaller exponent if a literal overflows. Text literals must contain valid Unicode: replace an unpaired surrogate escape with the intended character or a valid surrogate pair.

## SS1301

A `def` signature doesn't match the required shape.
Fix: write it as `def name(value: Number, scale: Number = 2) -> Number:` —
parameter names, `: Type` annotations, and an optional `-> ReturnType`.

## SS1302

A function calls itself directly or indirectly.
Fix: remove function recursion or use an iterative design. `shortcuts.run_self()` runs the entire shortcut recursively; it is not a drop-in function call and needs its own termination and input design.

## SS1303

A value function may finish without returning a value, or a helper uses a bare `return` where a value is required.
Fix: every continuing helper path needs `return expression`; a terminating `exit()` or `flow.stop()` path needs no value. A loop can run zero times, so a return only inside a loop needs a fallback afterward. Top-level `return expression` is supported: it shows the value and stops the shortcut. Bare top-level `return` stops without showing a value.

## SS1304

An imported file calls a function that doesn't exist in its imports.
Fix: check the function name and that the defining file is imported.

## SS1305

Helper arguments do not match the signature: missing, unknown, duplicate, or excessive arguments, or a positional argument after a named one.
Fix: put positional arguments first, then exact `name: value` pairs. Supply every required parameter once and inspect the helper declaration at the reported invocation.

## SS1306

The shortcut exceeded the build limit of 50,000 expanded steps. That includes work done to prepare function arguments, not just the actions you see in Shortcuts.
Fix: check the reported call chain and replace repeated calls with a loop where possible.

## SS1307

Function expansion exceeded its nesting budget. The default is 64 expansion levels, including nested control blocks and expression/default actions as well as helper invocations.
Fix: simplify deeply nested helpers or blocks. Use the reported call chain to find where the nesting starts.

## SS2001

A step refers to an output Studio can’t find, uses a value that might be missing, or leaves a path through the shortcut with no valid next step. Fix the error before exporting.
Fix: start with the line in the message. Set the value before using it, handle every branch that continues, and check for a missing value before passing it to an action.

## SS2002

A value contradicts a declared content contract.
Fix: pass a known compatible value, establish presence if needed, or use a supported explicit conversion. A cast does not prove runtime success, and `require()` does not establish a different content type.

## SS2004

A preserved plist UID cannot be represented in XML output.
Fix: export in binary format (`--binary` in the standalone CLI, or `binary=True` in the Python API). Do not convert an imported UID into a guessed string or number.

## SS2005

Imported native plist data exceeds the bounded size or depth limit, or contains a cycle that source cannot represent.
Fix: inspect the import and reduce its size or nesting if possible. Do not bypass the limits or silently drop native records to claim a complete import.

## SS2101

An action’s input could not be verified. Check the reason in the message:

- **Source type is unknown:** Inspect the action that produced the value. Use a source with the type the next action expects, or test the connection in Shortcuts.
- **No verified input type:** The action catalog doesn't confirm what this field accepts. Check the action in Shortcuts before adding a cast.
- **Conversion needed:** Use a source that already produces the required type, or use a supported explicit conversion. Add it explicitly.

Imported shortcuts can retain questionable connections as warnings so you can review them without changing what was imported.

## SS2102

A stored value is retrieved but never used.
Fix: use the retrieved value, or remove the unused retrieval if it is unnecessary. Do not remove an unrelated storage write merely to clear this warning.

## SS2103

An imported shortcut's output couldn't be resolved.
Fix: check the import link and that the referenced output still exists.

## SS2104

An action sits after the shortcut already returned or stopped on an earlier line, so it can never run.
Fix: move it above the `return`/`exit`/`stop`, or delete it if it's leftover.

## SS2105

A branch can never run because its condition is a literal `true` or `false`.
Fix: remove the dead branch, or replace the literal with the real condition you meant to test.

## SS2201

Arithmetic needs Number operands, but one side isn't a number.
Fix: establish presence and pass known Number operands, or use a supported numeric conversion. A presence check alone does not turn Text, a mixed union, or an unknown value into a Number.

## SS2202

A bare `if`/`guard`, ternary condition, or `and`/`or`/`not` operand has a non-Boolean type.
Fix: use a Boolean, an explicit comparison, `has value`, `is not empty`, or `if let`. A presence check and a true/false decision are different operations.

## SS2301

An action parameter, helper argument, or helper return violates its declared type contract.
Fix: inspect the expected type and the reported expression or invocation chain, establish presence if needed, and pass a compatible value. Use only a supported explicit conversion.

## SS2401

A native action requirement or field validation failed. A missing requirement may read `X requires: Y`; provide the named app, permission, or input. An out-of-range native numeric field is also reported here before export. Reduce that numeric value, or use quoted text if it is an exact long identifier rather than a number for arithmetic.

## Native authoring errors

A catalog declaration can exist without a valid serialized native action. When a diagnostic rejects a direct Shortcuts App Intent, choose a supported call rather than wrapping that identifier in `native_action`. For stopping the current shortcut, use `flow.stop()` or `exit()`.

For raw control-marker errors, replace newly authored marker calls with structured `if`, `menu`, `repeat`, or `for` blocks. Keep imported preservation records unless the requested edit requires changing them.

Use ordinary expressions in an `if` condition, not manually written variable attachments. `""` is valid when comparing against empty text.

Check the whole project again, then test the repaired shortcut on the intended device.

## SS2402

Two native producers or control markers share an action UUID.
Fix: assign the action result normally instead of specifying an ID. For imports, check the original reference rather than guessing a replacement.

## SS2403

An action UUID is malformed.
Fix: omit a newly authored `id` and reference the declared producer, or use a valid UUID only when manually maintaining native preservation source. AI drafts must not invent or rewrite preservation identities. Unchanged imported records require review.

## SS2404

An authored dictionary or list contains a value that Apple's editable collection fields cannot encode. This includes explicit `null` fields or items and unsupported native value wrappers.
Fix: omit the dictionary key or list item only when absence matches the intended behavior. If literal null must be preserved, use JSON text rather than an editable collection. For interpreter state, an explicit presence flag and a supported value can represent absence if that matches the language design. Do not silently replace null with zero or an empty string to make compilation pass. Bind other unsupported native values to a suitable action output or use a supported field value.

## Frequent source repairs

- **Named arguments:** Write `item(items, at: index)`, not `item(items, at = index)`. Give each label a value and use it only once.
- “Dictionary lookup requires a literal string key”: `record["title"]` is valid; replace `record[key_name]` with `value(record, key: key_name)`. For a list index use `item(items, at: index)` with one-based indexing. Handle a missing dictionary result before a required consumer.
- “Unknown Shortcuty Script call”: look up the exact call and parameters. `value(record, key: key_name)` is the core dictionary lookup; `dictionary.get_value` is not a supported synonym.
- A missing `files.pick` file: use `files.choose(select_multiple: false)` if the intent is a runtime picker, or supply the actual configured file. Do not fill the field with a guessed native dictionary.
- Optional output or arithmetic type errors: fix the source of absence or incompatible content, rather than replacing it with `require()` just to silence the checker.

## Migrating older source

The language now favors consistent, explicit semantics over compatibility with older authored source:

- `if ready:` and `guard ready else ...` test a Boolean's truth, not presence. To preserve an old presence check, write `if ready has value:` or `guard ready has value else ...`. Non-Boolean bare conditions now produce SS2202. `if let` keeps its presence semantics.
- Mixed `and`/`or` conditions now use standard `and`-before-`or` precedence. Older `a or b and c` grouped as `(a or b) and c`; rebuilding now means `a or (b and c)`. Write explicit parentheses to preserve intended old grouping. Both operands remain eager.
- Arithmetic binds before comparison in every expression context. `ok = price * quantity > limit` now means `ok = (price * quantity) > limit`, matching an `if` header. Parenthesize any deliberately different grouping.
- `#` is the source comment marker. Replace old `//` comments with `#`; `//` arithmetic is rejected instead of silently dropping its right-hand side. Slashes inside strings are unchanged.
- Build now rejects syntax errors in unused helper definitions, including loaded imports and defaults. Fix or remove those definitions rather than relying on them being unused.

Existing exported shortcuts do not change until rebuilt. Native preservation records keep their recorded conditions; these rules govern authored expressions. Re-check the complete project after migration and test rebuilt workflows on the intended device.

## SS2501

Invalid automation trigger declaration or missing original trigger data. Put one literal `triggers:` block before the entry shortcut’s actions. Use only exact supported calls, parameters and enum choices. Unknown native records can only be retained using their original imported fingerprint. Fix invalid source or reimport the unchanged original instead of inventing trigger fields. See [Triggers](/docs/triggers.md).

## SS2110

A native action output is read outside the If or Menu branch that produces it. That branch may not have run, so the value may be absent even when a similarly named variable was set elsewhere.
Fix: if the intent is to read the current mutable value, reference its named variable, such as `variable("operation")`, rather than the output of one branch's Set Variable action. If the intent is a particular action's snapshot, keep it and review the control flow. This is a conservative lexical warning, not proof of a runtime failure: paths that stop early can make the reference safe. Imported native wiring is preserved, never silently repaired. Test both branches on the intended device.
