{"record":{"id":"5d3235cf905c3456","repo":"dagger/dagger","slug":"unable-to-decode-input-argument-arg-name","errorCode":null,"errorMessage":"Unable to decode input argument '{arg_name}'","messagePattern":"Unable to decode input argument '(.+?)'","errorType":"exception","errorClass":"InvalidInputError","httpStatus":null,"severity":"error","filePath":"sdk/python/src/dagger/mod/_module.py","lineNumber":323,"sourceCode":"                raise InvalidInputError(msg, extra=extra) from e\n\n        inputs = {}\n        for arg in input_args:\n            # NB: These are already loaded by `input_args`,\n            # the await just returns the cached value.\n            arg_name = await arg.name()\n            arg_value = await arg.value()\n            try:\n                # Cattrs can decode JSON strings but use `json` directly\n                # for more granular control over the error.\n                inputs[arg_name] = json.loads(arg_value)\n            except ValueError as e:\n                logger.exception(\"Failed to decode JSON input value\")\n                msg = f\"Unable to decode input argument '{arg_name}'\"\n                extra = {\n                    \"json_value\": arg_value,\n                }\n                raise InvalidInputError(msg, extra=extra) from e\n\n        if logger.isEnabledFor(logging.DEBUG):\n            logger.debug(\n                \"invoke => %s\",\n                {\n                    \"parent_name\": parent_name,\n                    \"parent_json\": textwrap.shorten(parent_json, 144),\n                    \"name\": name,\n                    \"input_args\": textwrap.shorten(repr(inputs), 144),\n                },\n            )\n\n        result = await self.get_result(\n            parent_name,\n            parent_state,\n            name,\n            inputs,\n        )","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/sdk/python/src/dagger/mod/_module.py#L305-L341","documentation":"When invoking a function, each input argument arrives as a JSON-encoded value. If json.loads fails for a specific argument, invoke() raises InvalidInputError naming the argument and attaching the raw value as extra, because the function cannot be called without correctly decoded inputs.","triggerScenarios":"The engine (or a caller via `dagger call`) passes a value for argument {arg_name} that is not valid JSON — e.g. unquoted shell input like `--num abc` handled elsewhere but raw strings with bad quoting, or a caller SDK serializing incorrectly.","commonSituations":"Passing shell strings with special characters/unbalanced quotes to `dagger call --arg`; caller SDK version mismatch producing malformed payloads; JSON5-style input (trailing commas, single quotes) that strict json.loads rejects; piping truncated values.","solutions":["Inspect the json_value in the error's extra to see the malformed payload for that argument.","Quote/escape the argument on the CLI (e.g. `dagger call fn --arg '{\"a\":1}'` with correct shell quoting).","Ensure the value is strict JSON (double quotes, no trailing commas, no single quotes).","Align caller and module SDK versions; validate inputs with a JSON linter before invoking."],"exampleFix":"// before (shell)\ndagger call greet --name 'world's'   # bad quoting -> invalid JSON\n\n// after (shell)\ndagger call greet --name \"world's\"","handlingStrategy":"validation","validationCode":"import json\n\ndef validate_arg(name: str, raw: str) -> None:\n    try:\n        json.loads(raw)\n    except ValueError as e:\n        raise ValueError(f\"argument '{name}' is not valid JSON: {raw!r}\") from e","typeGuard":null,"tryCatchPattern":"try:\n    result = await module.invoke()\nexcept InvalidInputError as e:\n    logger.error(\"bad argument payload: %s | value=%r\", e, e.extra.get(\"json_value\"))\n    raise","preventionTips":["Quote CLI arguments carefully; test with `dagger call --debug`.","Pass strict JSON only (double quotes, no trailing commas).","Validate caller-side payloads with json.loads before sending.","Match caller SDK version with the module SDK."],"tags":["python","dagger","json","invalid-input","arguments"],"backgroundTag":"invalid-json-input","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}