iflytek/astron-agent · error · ValueError

Node has no variable

Error message

Node {node_id} has no variable {part_without_brackets}

What it means

get_template_unit resolves each {{variable}} placeholder in a template via variable_pool.get_variable_ref_node_id. When the pool has no reference node registered for that variable name on the given node, it raises ValueError, meaning the template references a variable that no upstream node produces.

Solutions

  1. Fix the placeholder name to match an actual upstream variable
  2. Reconnect or re-add the upstream node that produces the missing variable
  3. Use the workflow editor's variable picker instead of hand-typing placeholders
  4. Run workflow validation/debug to catch dangling references before execution

Example fix

# before
"Summarize {{user_query}}"  # no upstream node defines user_query
# after
"Summarize {{input.query}}"  # matches an existing upstream output
Defensive patterns

Strategy: validation

Validate before calling

refs = variable_pool.get_variable_ref_node_id(node_id, "user_query", span)
assert refs, "placeholder user_query has no upstream variable on this node"

Try / catch

try:
    units = get_template_unit(template, node_id, variable_pool, span)
except ValueError as e:
    logger.error(f"dangling template reference: {e}")
    raise

Prevention

When it happens

Trigger: Rendering a prompt template where a {{placeholder}} does not correspond to any variable defined by node_id, e.g. the upstream node was renamed/removed or the placeholder is misspelled.

Common situations: Editing a node's prompt after deleting an upstream node; typos in placeholder names; workflow version mismatch where the dependency edge no longer exists.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/70969a8c891b206a. Report an issue: GitHub.

Appendix: source

Thrown at core/workflow/engine/nodes/util/prompt.py:290

        if placeholders_with_brackets:
            pattern = "(" + "|".join(map(re.escape, placeholders_with_brackets)) + ")"
            parts = re.split(pattern, template)
        else:
            parts = [template]

        for i, part in enumerate(parts):

            if part == "":
                continue

            # Handle placeholder information
            if part in placeholders_with_brackets:
                part_without_brackets = part.removeprefix("{{").removesuffix("}}")
                ref_node_info = variable_pool.get_variable_ref_node_id(
                    node_id, part_without_brackets, span
                )
                if not ref_node_info:
                    raise ValueError(
                        f"Node {node_id} has no variable {part_without_brackets}"
                    )

                template_unit = TemplateUnitObj(
                    key=part_without_brackets,
                    key_type=TemplateSplitType.VARIABLE.value,
                    ref_node_info=ref_node_info,
                )

                if ref_node_info.ref_var_type == ValueType.LITERAL.value:
                    template_unit.key_type = TemplateSplitType.CONSTS.value
                    template_unit.value = ref_node_info.literal_var_value

                if (
                    template_unit.ref_node_info
                    and template_unit.ref_node_info.ref_var_type == ValueType.REF.value
                    and template_unit.ref_node_info.llm_resp_format
                    == RespFormatEnum.JSON.value

View on GitHub (pinned to 5e758547a8)