{"record":{"id":"91af129f3d8dba1f","repo":"iflytek/astron-agent","slug":"failed-to-convert-literal-value-input-key-to-type-json-input","errorCode":null,"errorMessage":"Failed to convert literal value {input_key} to type {json_input_type}, literal value: {input_content_org}","messagePattern":"Failed to convert literal value (.+?) to type (.+?), literal value: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/entities/variable_pool.py","lineNumber":380,"sourceCode":"                input_content: Any = \"\"\n                if input_value.type == ValueType.LITERAL.value:\n                    input_content = input_value.content\n                    input_content_org = input_content\n                    type_match = any(\n                        isinstance(input_content, t) for t in python_input_type_list\n                    )\n                    if not type_match:\n                        if json_input_type == \"boolean\":\n                            input_content = (\n                                False\n                                if input_content == \"false\" or input_content == \"False\"\n                                else True\n                            )\n                        else:\n                            try:\n                                input_content = ast.literal_eval(input_content)\n                            except Exception:\n                                raise Exception(\n                                    f\"Failed to convert literal value {input_key} to type {json_input_type}, literal value: {input_content_org}\"\n                                )\n                mapping_value = {\"value\": input_content, \"schema\": input_schema}\n                mapping_key = assemble_mapping_key(node_id, input_key)\n                self.input_variable_mapping.update({mapping_key: mapping_value})\n\n    def protocol_outputs_parser(self) -> None:\n        \"\"\"\n        Parse protocol outputs and populate output variable mapping.\n        \"\"\"\n        for node in self.nodes:\n            output_nodes = node.data.outputs\n            for output_node in output_nodes:\n                output_key = output_node.name\n                output_schema = output_node.output_schema\n                output_required = output_node.required\n                output_content = schema_type_default_value.get(\n                    output_schema.get(\"type\", \"\")","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/entities/variable_pool.py#L362-L398","documentation":"Raised in VariablePool.protocol_inputs_parser when ast.literal_eval cannot parse a declared-literal input string into the required JSON type. Literal inputs are parsed with Python's ast.literal_eval; a string that is not a valid Python literal (or not coercible to the target type) aborts parsing with this message.","triggerScenarios":"A workflow node input declared with a literal/json type contains content that literal_eval fails on — e.g. unquoted free text intended as a string, malformed JSON, single quotes in numeric-looking values, or template remnants like '{{var}}'.","commonSituations":"Users typing plain sentences into fields typed as numbers/booleans/lists; copying JSON with trailing commas; config exported from another tool with different literal syntax; unresolved mustache placeholders left in the value.","solutions":["Quote string literals explicitly (e.g. '\"some text\"') or change the input type to string so literal_eval is not applied","Fix the literal syntax of the value (valid Python literal: numbers, True/False, lists, dicts)","Pre-validate the value with ast.literal_eval in a try/except before saving the workflow","Sanitize/resolve template placeholders before the input reaches protocol_inputs_parser"],"exampleFix":"// before\ninput_content = \"Hello world\"  # typed as number -> literal_eval fails\n// after\ninput_content = '\"Hello world\"'  # or declare input type as string","handlingStrategy":"validation","validationCode":"import ast\ntry:\n    ast.literal_eval(input_content)\nexcept (ValueError, SyntaxError):\n    raise ValueError(f\"'{input_content}' is not a valid literal for type {json_input_type}\")","typeGuard":"def is_valid_literal(s: str) -> bool:\n    import ast\n    try:\n        ast.literal_eval(s)\n        return True\n    except (ValueError, SyntaxError):\n        return False","tryCatchPattern":"try:\n    parsed = ast.literal_eval(raw)\nexcept Exception:\n    parsed = raw  # treat as plain string instead of failing","preventionTips":["Type free-text inputs as string so literal_eval is skipped","Validate literal fields in the workflow editor before saving","Resolve template placeholders before protocol parsing"],"tags":["workflow","parsing","literal","ast","python"],"backgroundTag":"invalid-argument-format","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"}