iflytek/astron-agent · error · Exception
key does not exist
Error message
key {key} does not exist What it means
VariablePool.iteration_array resolves iteration array mappings; when the mapping schema describes an array of objects, it looks up the requested key in the object's properties schema and raises Exception('key {key} does not exist') if absent. This ensures only keys declared in the object item schema can be extracted during iteration, failing fast on schema/reference mismatches.
Solutions
- Add the missing key to the array variable's items.properties schema in the variable mapping
- Update the iteration node to reference an existing field name from the schema
- Ensure the upstream node that produces the array declares all fields its consumers read (stabilize output schema)
- Validate mapping schemas at build time so key mismatches surface before execution
Example fix
// before: reading 'userName' but schema only declares 'name'
{"items": {"type": "object", "properties": {"name": {"type": "string"}}}}
// after: align key or schema
{"items": {"type": "object", "properties": {"name": {"type": "string"}, "userName": {"type": "string"}}}} Defensive patterns
Strategy: validation
Validate before calling
def key_in_array_schema(mapping_schema, key):
items = mapping_schema.get("items", {})
if items.get("type") == "object":
return key in items.get("properties", {})
return True Type guard
def can_extract_key(mapping_schema, key) -> bool:
props = mapping_schema.get("items", {}).get("properties", {})
return key in props Try / catch
try:
arr = pool.iteration_array(key=field, mapping_schema=schema, ...)
except Exception as e:
if str(e).startswith("key ") and "does not exist" in str(e):
# fix field name or extend items.properties schema, then retry
...
raise Prevention
- Stabilize upstream node output schemas so consumer fields always exist
- Update iteration nodes whenever an object field is renamed
- Validate variable mapping schemas at workflow build time
When it happens
Trigger: Requesting iteration_array for an object-typed array variable with a key that is not declared in that array's items.properties mapping schema — e.g. iterating over records and reading a field that was never defined in the variable's schema.
Common situations: Renaming an object field in an upstream node (LLM/code output) while iteration nodes still reference the old field name; schema inferred from a first record that lacks the field; hand-edited variable mapping schemas missing the key.
Related errors
- VARIABLE_POOL_SET_PARAMETER_ERROR
- VARIABLE_POOL_GET_PARAMETER_ERROR
- 8118
- Header mismatch! Expected headers: , Actual headers:
- 8517
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/4762ce60945a94a6.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/engine/entities/variable_pool.py:95
:param first_only: If True, extract only the first element for array object types
:return: Extracted value based on key navigation
"""
mapping_value: Any = content
mapping_schema: dict = cast(dict, schemas) # Ensure not None
key_type: str = mapping_schema.get("type", "")
key_i = 0
for key in key_list:
if key_i == 0:
key_i += 1
continue
mapping_schema = cast(dict, mapping_schema)
if key_type == "array":
mapping_schema = cast(dict, mapping_schema.get("items", {}))
array_type = mapping_schema.get("type")
if array_type == "object":
mapping_schema = cast(dict, mapping_schema.get("properties", {}))
if key not in mapping_schema:
raise Exception(f"key {key} does not exist")
mapping_schema = cast(dict, mapping_schema[key])
key_type = mapping_schema.get("type", "")
mapping_value = cast(list, mapping_value)
if first_only:
if mapping_value:
mapping_value = mapping_value[0].get(
key, schema_type_default_value.get(key_type)
)
else:
mapping_value = schema_type_default_value.get(key_type)
else:
return [
iteration_array(
value.get(key, schema_type_default_value.get(key_type)),
mapping_schema,
key_list[key_i:],
first_only=first_only,View on GitHub (pinned to 5e758547a8)