dagger/dagger · error · InvalidInputError
'")} This could be an error in the Python SDK. If so…
Error message
{transform_error(e, "Failed to instantiate parent object '{obj_type}'")}
This could be an error in the Python SDK. If so, please file a bug report. What it means
Before invoking a method, the SDK instantiates the parent object by structuring the engine-provided `state` (its field values) into the object's class via cattrs (`structure(state, obj_type.cls)`). Any failure there is wrapped as `InvalidInputError` with a `transform_error` message and the note 'This could be an error in the Python SDK. If so, please file a bug report.', because the API supposedly validated these values against the registered schema — a mismatch usually indicates registration/serialization drift.
Solutions
- Read the transformed message: it names the field and expected type that failed to structure, plus `object_state` in the extra details.
- Simplify or align the object's field annotations with Dagger-supported types (scalars, lists, Optional, other object types, enums).
- Round-trip: make sure the field type used at registration is identical to the current class annotation; redeploy the module so registration is refreshed.
- If types look right, try a minimal repro and file a bug at dagger/dagger — the message explicitly suggests an SDK bug.
- Update the Python SDK to the latest version; several cattrs-related structuring bugs have been fixed over time.
Example fix
# before
@dagger.object_type
class Cache:
data: dict # bare dict may fail cattrs structuring of state
# after
@dagger.object_type
class Cache:
data: dict[str, str] Defensive patterns
Strategy: validation
Validate before calling
import dataclasses
def validate_fields(cls) -> list[str]:
bad = []
for f in dataclasses.fields(cls):
t = f.type
if isinstance(t, str):
bad.append(f"{f.name}: string annotation '{t}' may not structure")
return bad
# run at module load: print(validate_fields(MyObject)) Try / catch
try:
res = await session.call_fn("MyObject.method", parent_state={...})
except dagger.InvalidInputError as e:
if "Failed to instantiate parent object" in str(e):
logger.error("state incompatible with class: %s state=%s", e, e.extra.get("object_state")) Prevention
- Use only Dagger-supported field types (scalars, list, Optional, enums, object types) in object_type classes
- Keep field annotations concrete (dict[str, str], not bare dict)
- Update the Python SDK regularly; report genuine structuring bugs to dagger/dagger as the message suggests
- Redeploy the module after any field type change so stored state and schema stay in sync
When it happens
Trigger: Calling a method on an object whose stored fields can't be structured into the declared dataclass: a field's registered type is incompatible with cattrs (e.g. unsupported generic/union), the field's Python type changed after the value was stored, or a required field is absent from the state.
Common situations: Using exotic types in `@dagger.object_type` fields that pass registration but fail cattrs unstructure/structure round-trips; changing a field's annotation while old state persists; SDK bugs with certain Optional/generic field combos — hence the bug-report hint.
Related errors
- '")} This could be an error in the Python SDK. If so…
- Please check if the returned value at runtime matches the…
- Async function ' ' was never awaited. Did you forget to add…
- Class ' ' is not an enum.Enum subclass
- {e}
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/795652c1c80a87c8.
Report an issue: GitHub.
Appendix: source
Thrown at sdk/python/src/dagger/mod/_module.py:513
return await self.structure(state, obj_type.cls)
except Exception as e:
log_exception_only(e, "Failed to instantiate parent object")
msg = transform_error(
e,
f"Failed to instantiate parent object '{obj_type}'",
origin=obj_type.cls,
typ=obj_type.cls,
)
# If API is able to make the call this is likely a bug in the SDK.
# For example, if the registration phase reports a type that isn't
# compatible with cattrs' converter.
msg += (
"\n"
"This could be an error in the Python SDK. "
"If so, please file a bug report."
)
extra = {"object_state": state}
raise InvalidInputError(msg, extra=extra) from e
async def _convert_inputs(
self,
fn: Function,
inputs: Mapping[APIName, Any],
) -> Mapping[PythonName, Any]:
"""Convert arguments from lower level primitives to the expected types."""
kwargs = {}
# Convert arguments to the expected type.
for python_name, param in fn.parameters.items():
if param.name not in inputs:
if not param.is_optional:
msg = f"Missing required function argument '{python_name}'"
raise InvalidInputError(msg)
if param.has_default:
continueView on GitHub (pinned to 82ba2681db)