{"record":{"id":"7eebf7b56f3a92e2","repo":"iflytek/astron-agent","slug":"join-er-msgs","errorCode":null,"errorMessage":"{';'.join(er_msgs)}","messagePattern":"\\{';'\\.join\\(er_msgs\\)\\}","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/entities/variable_pool.py","lineNumber":827,"sourceCode":"        \"\"\"\n        required = []\n        schemas: dict = copy.deepcopy(self.validate_template)\n        for mapping_key in self.output_variable_mapping.keys():\n            if mapping_key.startswith(node_id):\n                mapping_value = self.output_variable_mapping[mapping_key]\n                value_schema = mapping_value.get(\"schema\")\n                key = mapping_key.split(f\"{node_id}-\")[-1]\n                schemas[\"properties\"].update({key: value_schema})\n                if mapping_value.get(\"required\", False):\n                    required.append(key)\n        if required:\n            schemas.update({\"required\": required})\n        er_msgs = [\n            f\"Field: {er['schema_path']}, Error: {er['message']}\"\n            for er in CNValidator(schemas).validate(outputs)\n        ]\n        if er_msgs:\n            raise Exception(f\"{';'.join(er_msgs)}\")\n\n    async def add_variable(\n        self,\n        node_id: str,\n        key_name_list: list[str],\n        value: NodeRunResult,\n        span: Span,\n    ) -> None:\n        \"\"\"\n        Add variables to the variable pool with validation.\n\n        :param node_id: ID of the node\n        :param key_name_list: List of variable names to add\n        :param value: NodeRunResult containing output and error values\n        :param span: Span object for tracing\n        \"\"\"\n        output_value = value.outputs\n        if node_id.split(\":\")[0] == \"node-end\":","sourceCodeStart":809,"sourceCodeEnd":845,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/entities/variable_pool.py#L809-L845","documentation":"do_validate runs CNValidator against a node's outputs using its declared schema and, if any validation errors are returned, raises a plain Exception joining all messages as 'Field: <path>, Error: <message>; ...'. It is schema validation of node output data against the node's output JSON schema.","triggerScenarios":"do_validate(node_id, outputs) — invoked from add_init_variable and async_execute — when outputs do not conform to the node's declared schema: missing required fields, wrong types, or failing nested constraints.","commonSituations":"Node implementation returns data whose shape differs from its declared output schema (e.g. returns string where object expected); optional fields emitted as null when required; schema tightened after node code was written.","solutions":["Read the joined messages — each names the failing field path and reason — and fix the node's returned data to match the schema","Update the node's declared output schema to correctly describe what it actually returns","Ensure required fields are always populated (or marked not-required) before do_validate runs","Add unit tests comparing real node outputs against the schema to catch drift early"],"exampleFix":"// before\nreturn {\"count\": \"5\"}  # schema says integer\n// after\nreturn {\"count\": 5}  # matches declared schema type","handlingStrategy":"validation","validationCode":"errors = CNValidator(schemas).validate(outputs)\nassert not errors, [f\"{e['schema_path']}: {e['message']}\" for e in errors]","typeGuard":"def outputs_match_schema(outputs: dict, schemas: dict) -> bool:\n    return not CNValidator(schemas).validate(outputs)","tryCatchPattern":"try:\n    pool.do_validate(node_id, outputs)\nexcept Exception as e:\n    for msg in str(e).split(';'):\n        log.error(f\"output validation: {msg}\")\n    raise","preventionTips":["Unit-test node outputs against their declared schemas","Keep the output schema definition in sync with what the node code returns","Mark truly optional fields as not-required instead of emitting nulls"],"tags":["workflow","schema-validation","output","python"],"backgroundTag":"schema-validation-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}